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

What's wrong with my script?

Asked by 10 years ago

I have a script that is suppose to make me go to the creator spawn in the game and my friends to the friend spawn. I have the spawn locations named "CreatorSpawn" and "FriendSpawn" but it still won't work. Please help.

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.Character:MoveTo(FriendSpawn.Position)
end)
end
end)

Answer this question