I would revert back to this script for now since it worked somewhat and give me a little bit while I recreate what you have going on in studio and see if I can’t figure it out for you.
local players = {}
local tournamenton = false
while wait(10) do
players = {}
for i, player in pairs(game.Players:GetPlayers()) do
local c = ui:Clone()
c.Parent = player.PlayerGui
local bonksamountwin = math.random(100, 250)
c.OuterFrame.Prize.Text = "A bonk challenge is starting with a prize of " .. bonksamountwin .. " bonks."
c.OuterFrame.YES.MouseButton1Click:Connect(function()
c:Destroy()
tournamenton = true
players = {player}
player.Character:MoveTo(workspace.Tournament.tp.Position)
player.Character.Humanoid.Died:Connect(function()
local index = table.find(players, player)
table.remove(players, index)
end)
if #players >= 2 then -- Added if statment before the loop.
while wait(1) do
if #players == 1 then
local winner = script.WINNER:Clone()
winner.WINNER.Visible = true
winner.WINNER.Text = player.Name .. " HAS WON " .. bonksamountwin .. " BONKS!"
player.Character.Humanoid.Health = 0
player.leaderstats.Bonks.Value += bonksamountwin
wait(2)
winner:Destroy()
tournamenton = false
break
end
end
end
end)
c.OuterFrame.NO.MouseButton1Click:Connect(function()
c:Destroy()
end)
wait(7)
c:Destroy()
end
end