Answered by
5 years ago Edited 5 years ago
I think whats happening here is either:
A) The character hasnt been loaded in;
B) You might not be running this in a local script
2 | plr = game.Players.LocalPlayer |
3 | char = plr.Character or plr.CharacterAdded:Wait() |
5 | click = game.Workspace.DieButton.Button.ClickDetector |
6 | click.MouseClick:Connect( function () |
7 | char.Humanoid:MoveTo(game.Workspace.Die.Position) |
The reason this works is because or
turns this into a conditional statement.
If Player.Character comes back as nil, it goes to the next condition, which is the CharacterAdded event. It then halts the script from continuing until theres a character loaded in.
Hopefully that helps.
https://developer.roblox.com/en-us/api-reference/property/Player/Character