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 9 years ago

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

Log in to vote
0
Answered by 9 years ago
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...

0
I put it in my game and played the game, but, I didn't get teleported to the Owner Spawn titan111 0 — 9y
Ad

Answer this question