Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i access a character from a tool?

i am only able to find the player in game.players but i cant find the character in game.Workspace by using my tool

1 answer

the character can be found two ways. The first way is by using :FindFirstChild()

if game.Players.LocalPlayer then
local plr=game.Workspace:FindFirstChild(game.Players.LocalPlayer)
end

the other way(the one thats better to use) is by using plr.Character

local plr=game.Players.LocalPlayer.Character

also, you could just get the localplayer when the tool is equipped

local tool=script.Parent
local plrcheck=false
local plr
local debounce=false
tool.Equipped:Connect(function()

if plrcheck==false and not debounce then
debounce=true
plr=script.Parent.Parent

wait(0.1)
plrcheck=true
debounce=false
end


end


end)

3 comments

0

Note that this only will work in a LocalScript. A Script (running on the server) will have a LocalPlayer of nil.

0

i know, tools are localized

0

thats why i added the last one b/c it doesnt need a localscript

This discussion is preserved as it was. New answers, comments, and votes are closed.