File tree 1 file changed +41
-6
lines changed
1 file changed +41
-6
lines changed Original file line number Diff line number Diff line change 1
- -- This script is getting deleted soon
2
- return {
3
- GetPlayers = function ()
4
- return require (game :GetService (" ReplicatedStorage" ).shared .PlayerStates ):GetPlayersWithState (1 )
5
- end ,
6
- }
1
+ -- Copyright (C) 2023 Tria
2
+ -- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
3
+ -- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
+
5
+ -- < Services >--
6
+ local ReplicatedStorage = game :GetService (" ReplicatedStorage" )
7
+
8
+ local PlayerStates = require (ReplicatedStorage .shared .PlayerStates )
9
+
10
+ -- < Main >--
11
+ local Players = {}
12
+ Players .__index = Players
13
+
14
+ function Players .new ()
15
+ local self = setmetatable ({}, Players )
16
+ return self
17
+ end
18
+
19
+ --- Description
20
+ function Players :GetPlayers ()
21
+ return PlayerStates :GetPlayersWithState (PlayerStates .GAME )
22
+ end
23
+
24
+ --- Description
25
+ -- 0.11 Feature
26
+ function Players :GetPlayersInRadius (position : Vector3 , radius : number ): { Player }
27
+ local ret = {}
28
+
29
+ for _ , plr in pairs (self :GetPlayers ()) do
30
+ if plr and plr .Character then
31
+ local rootPart = plr .Character :FindFirstChild (" HumanoidRootPart" )
32
+ if rootPart and ((rootPart .Position - position ).Magnitude <= radius ) then
33
+ table.insert (ret , plr )
34
+ end
35
+ end
36
+ end
37
+
38
+ return ret
39
+ end
40
+
41
+ return Players
You can’t perform that action at this time.
0 commit comments