Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

Ad
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago
script.Parent.Activated:Connect(function(player)
    print(player.Name)
end)

Answer this question