Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created September 14, 2022 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shilo/0a8be06d6137b77e87e77a1ee390bf6e to your computer and use it in GitHub Desktop.
Save Shilo/0a8be06d6137b77e87e77a1ee390bf6e to your computer and use it in GitHub Desktop.
Tool helper methods to get player and character objects in Roblox Studio.
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