Created
September 14, 2022 08:53
-
-
Save Shilo/0a8be06d6137b77e87e77a1ee390bf6e to your computer and use it in GitHub Desktop.
Tool helper methods to get player and character objects in Roblox Studio.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function GetPlayerFromTool(tool) | |
return game:GetService("Players"):GetPlayerFromCharacter(tool.Parent) or tool:FindFirstAncestorWhichIsA("Player") | |
end | |
local function GetCharacterFromTool(tool) | |
local player = GetPlayerFromTool(tool) | |
return player and player.Character | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment