I made a button that's supposed to lead your character of a cliff, but it didn't work. This is the code I used.
plr = game.Players.LocalPlayer
char = plr.Character
click = game.Workspace.DieButton.Button.ClickDetector
click.MouseClick:Connect(function()
char.Humanoid:MoveTo(game.Workspace.Die.Position)
end)
and it came out with an error: Players.marioman1932.PlayerScripts.Die:5: attempt to index global 'char' (a nil value) but it's not a nil value because I made a variable for it. Please help of why it says that. Edit: Yes this is in a local script.

5 comments
I think it depends if you're using a localscript, or a script. If this is a localscript, it has to work. If you are using a normal script, try click.MouseClick:Connect(function(player)
sorry i didnt read the edit, i honestly dont know why it isnt working
This is because you need to wait for the character to load
How do I do that? (post it in the answer bar)
I did but deleted it because @psudar's is better