Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's wrong with this script?

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.

local CreatorSpawn = Workspace:FindFirstChild("CreatorSpawn") --Find the CreatorSpawn
local FriendSpawn = Workspace:FindFirstChild("FriendSpawn") --Find the FriendSpawn
Game.Players.PlayerAdded:connect(function(Player) --When they join
if Player.userId == Game.CreatorId then --If they are the creator
Player.CharacterAdded:connect(function(Character)
Character:MoveTo(CreatorSpawn.Position) --Teleport them to the CreatorSpawn when they spawn.
end)
elseif Player:IsFriendsWith(Game.CreatorId) then --Otherwise if they are friends with the creator
Player.CharacterAdded:connect(function(Character)
Character:MoveTo(FriendSpawn.Position) --Teleport them to the FriendSpawn.
end)
end
end)

1 comment

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

1 answer

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.

1 comment

0

this doesn't seem to work

This discussion is preserved as it was. New answers, comments, and votes are closed.