In my game, I have a minigame where each player takes in turns to complete the obby.
If the player falls (or fails), it will touch and invisible brick on the floor, stop their turn, teleport them to the waiting podium, take their name out of a global table and change their team to an other team. If a player completes it, the player will stay on the team and in the table, their score will be increased by 1 and their turn will end.
This is the script;
local replicatedStorage = game:GetService('ReplicatedStorage') local status = replicatedStorage:WaitForChild('InfoValue') local inGamers = game.Teams.Players:GetPlayers() local loops = 0 local MG = game.Workspace.Minigame:FindFirstChild("ObbyMinigame") local teleTo = MG.TeleportToSpawn local finishPart = MG.CompletePart local failPart = MG.FailPart local spawns = game.Workspace.Minigame:FindFirstChild("ObbyMinigame"):FindFirstChild("Spawns"):GetChildren() local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] repeat for i, v in pairs(game.Teams.Players:GetPlayers()) do v.Character.Torso.CFrame = CFrame.new(teleTo.Position + Vector3.new(0, 2, 0)) for t = 30, 1, -1 do if t == 1 then status.Value = v.Name.." has "..t.." second to complete the obby." else status.Value = v.Name.." has "..t.." seconds to complete the obby." end if finishPart.Completed.Value == true then local completePlayer = game.Players:FindFirstChild(v.Name) completePlayer.Score.Value = completePlayer.Score.Value + 1 t = 1 finishPart.Completed.Value = false break elseif failPart.Failed.Value == true then for num, failPlayer in pairs(_G.minigame) do if failPlayer == v.Name then table.remove(_G.minigame, num) v.TeamColor = BrickColor.new('Black') end end t = 1 failPart.Failed.Value = false break end wait(1) end end loops = loops + 1 until #inGamers <= 1 or loops == 5 script.Disabled = true
In the 'FailPart' and 'CompletePart', I have a BoolValue and a script that does this;
-- In CompletePart local spawns = game.Workspace.Minigame:FindFirstChild("ObbyMinigame"):FindFirstChild("Spawns"):GetChildren() local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] script.Parent.Touched:connect(function(char) script.Parent.Completed.Value = true -- FailPart says 'script.Parent.Failed.Value = true' char.Torso.CFrame = CFrame.new(randomspawn.Positon + Vector3.new(0, 5, 0)) end)
No errors in the output.