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

Please Help and Fix this for me!?

Asked by 9 years ago

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!

0
You are using the function incorrectly, or, as I should say, typed it incorrectly, on line 4. TheeDeathCaster 2368 — 9y
0
So what should it be? CjGamer1454 0 — 9y
0
You did not add the parentheses, or the '()' things, I should say. TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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)
0
No need to wait for the LocalPlayer, it will always exist. I'm also pretty sure :wait() only works on events. Perci1 4988 — 9y
Ad

Answer this question