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

How do I get a Player's character?

I made a script but I keep getting a error in the output.

Workspace.Brick..Head.Script:4: attempt to index field 'Character' (a nil value)

script.Parent.Touched:connect(function(hit)
name = hit.Parent.Name
print(name.Character.userId)
end)

1 answer

✓ Accepted answer

Try this;

local debounce=false
script.Parent.Touched:connect(function(hit)
if not debounce then
debounce=true
plr=game.Players:GetPlayerFromCharacter(hit.Parent)
print(plr.Character.Name)
end
wait(2)
debounce=false
end)

I hope this helped!

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