Hi everyone.
I am trying to make a round-based game, with a turtorial arena when a player joins for the first time.
The round based game works fine- it starts in the lobby, then the arena, then the victory arena, then repeats the process.
When a new player joins for the first time, however, I check for a badge, which is awarded at the end of the tutorial (this works). When I use the code below the whole cycle stops working. It takes me to the lobby, and that is all.
Any ideas why?
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
humanoid.Health = 100
humanRoot.CFrame = game.Workspace.ArenaStartPart.CFrame
end
else
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
humanoid.Health = 100
humanRoot.CFrame = game.Workspace.LobbyStartPart.CFrame
end
end
end)
local function round()
while true do
inRound.Value = false
for i = INTERMISSION, 0, -1 do
wait(1)
end
inRound.Value = true
for i = ROUND_LENGTH, 0, -1 do
wait(1)
end
--Victory Screen
for i, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
humanRoot.CFrame = game.Workspace.SkyPart.CFrame
status.Value = ""
end
inRound.Value = false
end
end
game.Players.PlayerAdded:Connect(function(plr)
if not badgeServ:UserHasBadgeAsync(plr.UserId,firstTimeBadge) then
print(("Doesnt own badge"))
game.Workspace.TutorialSpawnLocation.Enabled = true
else
spawn(round)
end
end)