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

When im printing the player, why does it come back as nil?

The local script is in a tool, and when you activate it (click) then it will get the player who clicks. When i try to print the player who clicks it returns as nil in output. Any ideas?

script.Parent.Activated:Connect(function(plr)
	print(plr)
end)

thanks for any help

2 answers

The problem is there is no such property (or whatever you call it) in this event so you can't get a Player by this method. Since it is in a local script, all you need to do is to replace 'player' to game.Players.LocalPlayer so you want this code below.

script.Parent.Activated:Connect(function()
	print(game.Players.LocalPlayer) -- likejagar
end)

If I understand what you trying to do, you will face some issues (but I don't really know why you need this). If you have some problems with this, just ask me in the comments below.

script.Parent.Activated:Connect(function(player)
    print(player.Name)
end)

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