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

What's wrong with this script?

Asked by 11 years ago

The script is supposed to make the creator of the game spawn on the creator's spawn and friends on their spawn, but it doesn't work.

01local CreatorSpawn = Workspace:FindFirstChild("CreatorSpawn") --Find the CreatorSpawn
02local FriendSpawn = Workspace:FindFirstChild("FriendSpawn") --Find the FriendSpawn
03Game.Players.PlayerAdded:connect(function(Player) --When they join
04if Player.userId == Game.CreatorId then --If they are the creator
05Player.CharacterAdded:connect(function(Character)
06Character:MoveTo(CreatorSpawn.Position) --Teleport them to the CreatorSpawn when they spawn.
07end)
08elseif Player:IsFriendsWith(Game.CreatorId) then --Otherwise if they are friends with the creator
09Player.CharacterAdded:connect(function(Character)
10Character:MoveTo(FriendSpawn.Position) --Teleport them to the FriendSpawn.
11end)
12end
13end)
0
Your script is really messy. Try indenting every time you start a new process http://wiki.roblox.com/index.php?title=Writing_Clean_Code Maxomega3 106 — 11y

1 answer

Log in to vote
0
Answered by
Maxomega3 106
11 years ago

The problem most likely is that your variables at the beginning run out of scope before you can use them in your script. Try removing the "local" at the beginning to make them global variables.

0
this doesn't seem to work titan111 0 — 11y
Ad

Answer this question