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 my script?

This is suppose to make the creator of the game go to the creator spawn and the creators friends go to the friend spawn when they die or join the game. I have the creator spawn named "CreatorSpawn" and the friend spawn named "FriendSpawn" but the script doesn'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:MoveTo(FriendSpawn.Position) --Teleport them to the FriendSpawn.
end)
end
end)

1 answer

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 --changed this line
end)
end
end)

Pretty simple. The Character in the line I change is just the Player in game.Players. You need to get the character by using Character.Character:MoveTo...

1 comment

0

I put it in my game and played the game, but, I didn't get teleported to the Owner Spawn

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