File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ --[=[
2+ @class ToolUtils
3+ ]=]
4+
5+ local require = require (script .Parent .loader ).load (script )
6+
7+ local CharacterUtils = require (" CharacterUtils" )
8+
9+ local ToolUtils = {}
10+
11+ --[=[
12+ Gets the equipped humanoid for a given tool
13+ ]=]
14+ function ToolUtils .getEquippedHumanoid (tool : Tool ): Humanoid ?
15+ assert (typeof (tool ) == " Instance" , " Bad tool" )
16+
17+ local character = tool .Parent
18+ if not (character and character :IsA (" Model" )) then
19+ return nil
20+ end
21+
22+ local humanoid = character :FindFirstChildWhichIsA (" Humanoid" )
23+ if not humanoid then
24+ return nil
25+ end
26+
27+ return humanoid
28+ end
29+
30+ --[=[
31+ Gets the equipped player for a given tool
32+ ]=]
33+ function ToolUtils .getEquippedPlayer (tool : Tool ): Player ?
34+ assert (typeof (tool ) == " Instance" , " Bad tool" )
35+
36+ local humanoid = ToolUtils .getEquippedHumanoid (tool )
37+ if not humanoid then
38+ return nil
39+ end
40+
41+ return CharacterUtils .getPlayerFromCharacter (humanoid )
42+ end
43+
44+ return ToolUtils
You can’t perform that action at this time.
0 commit comments