I made a script that when a player spawns, he will be transfered to the so-called Lobby baseplate. After a 10 second intermission, the players will be transfered to the positions of the random part of a map. After 5 minutes, they will return to Lobby once more.
I fixed the problems in the output but when I tried it nothing happened. My character didn't even go to the Lobby. Can someone tell me what's wrong? And, thanks in advance
This is the script:
print("Lobby Script Online...")
local lobby = script.Parent
local debounce = false
local teams = game:GetService("Teams")
local neutral = Instance.new("Team", teams)
if not game.Workspace:FindFirstChild("CurrentMap") then
local model = Instance.new("Model", game.Workspace)
model.Name = "CurrentMap"
end
neutral.Name = "Neutral" ; neutral.TeamColor = BrickColor.Gray()
lobby.Anchored = true
game.Players.PlayerAdded:connect(function(player)
if not debounce then
debounce = true
player:WaitForChild("Character"):MoveTo(lobby.Position)
player.TeamColor = BrickColor.Gray()
player.Neutral = true
debounce = false
end
end)
while true do
local players = {}
players = game.Players:GetPlayers()
for _, v in pairs(players) do
local maptable = {}
math.randomseed(tick())
maptable = game.Workspace:WaitForChild("CurrentMap"):GetChildren()
players[_]:WaitForChild("Character"):MoveTo(
maptable[math.random(#maptable)].Position)
end
wait(300)
for p = 1, #players, 1 do
players[p]:WaitForChild("Character"):MoveTo(lobby.Position)
end
wait(10)
end
