So I made this script and I inserted it to Workspace > Part > SurfaceGui > TextButton I need it to teleport me to a brick "SpawnLocation1", but when I clicked the SurfaceGui TextButton, it did nothing, please help
spawn = game.Workspace.SpawnLocation1
player = script.Parent.Parent.Parent.Parent
function onClicked()
player.Character:MoveTo(spawn.Position)
end
script.Parent.MouseButton1Down:connect(onClicked)
When I clicked it, it didn't work. I saw this error in the output, I'm a newbie scripter so I don't know what how Character is not a valid member of Workspace.
19:54:47.303 - Character is not a valid member of Workspace 19:54:47.305 - Script 'Workspace.Part.SurfaceGui.TextButton.Script', Line 5 19:54:47.307 - Stack End
I have no idea how to fix this.

1 comment
Please edit your post to use Lua code formatting