What's Wrong With Line 5?!?!?!
spawn = game.Workspace.SpawnLocation player = script.Parent.Parent.Parent.Parent function onClicked player.Character:MoveTo(spawn.Position) -- '(' expected near 'player' end script.Parent.MouseButton1Down(onClicked) for index, player in pairs(game.Players:GetPlayers()) do print(player.Name) end
My previous question was my Teleport GUI Help and it wasn't answered quite right or I just didn't understand the script. The Script that I made:
spawn = game.Workspace.SpawnLocation player = script.Parent.Parent.Parent.Parent function onClicked player.Character:MoveTo(spawn.Position) end script.Parent.MouseButton1Down(onClicked)
But then yumtaste (who answered my question) said to incorporate this:
for index, player in pairs(game.Players:GetPlayers()) do print(player.Name) end
to my script but I'm having trouble. Can you please help me? I need a complete script ASAP. Thx guys!
Your top code should be more around this - You merely had a syntax error:
spawn = workspace.SpawnLocation player = script.Parent.Parent.Parent.Parent function onClicked() player.Character:MoveTo(spawn.Position) end script.Parent.MouseButton1Down:connect(onClicked) --[[ for index, player in pairs(game.Players:GetPlayers()) do print(player.Name) end]]-- I don't see a use for this segment of code
I'd also recommend using a local-script for what you are trying to achieve.
IF YOU USE A LOCALSCRIPT:
spawn = workspace["SpawnLocation"] plr = game.Players.LocalPlayer or game.Players.LocalPlayer:wait() script.Parent.MouseButton1Down:connect(function() plr.Character:MoveTo(spawn.Position) end)