so i have this part of a script:
local guifortexttobeshown = Instance.new("ScreenGui")
guifortexttobeshown.Name = "CountdownGui"
guifortexttobeshown.Parent = player:FindFirstChild("PlayerGui")
local guiClone2 = StarterGui:WaitForChild("TournamentStartingGui").Text:Clone()
guiClone2.Name = "CountdownText"
guiClone2.Parent = guifortexttobeshown -- Ensure the cloned GUI is parented to the player's GUI
guiClone2.Visible = true
guiClone2.Text = "3"
wait(1)
guiClone2.Text = "2"
wait(1)
guiClone2.Text = "1"
wait(1)
guiClone2.Text = "FIGHT"
local punchTool = StarterPack:FindFirstChild("Punch")
if punchTool then
punchTool:Clone().Parent = player.Character
end
and i was wondering how to make it so that this happens so when the tournament gui appears for each player, after 10 seconds if there are players then the script i just gave above happens for each player, and also how do i make it so that if the tournament started with only 1 player they dont get 500 points heres the tournament script:
-- Tournament Script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local Workspace = game:GetService("Workspace")
local StarterPack = game:GetService("StarterPack")
local tournamentGui = StarterGui:WaitForChild("TournamentGui")
local teleportSpawn = Workspace:WaitForChild("TournamentSpawn")
local tournamentPlayers = {}
local tournamentActive = false
local function monitorTournament(player)
while tournamentActive do
for i = #tournamentPlayers, 1, -1 do
local player = tournamentPlayers[i]
if not player.Character or not player.Character:FindFirstChild("Humanoid") or player.Character.Humanoid.Health <= 0 then
table.remove(tournamentPlayers, i)
end
end
if #tournamentPlayers == 1 then
local winner = tournamentPlayers[1]
local leaderstats = winner:FindFirstChild("leaderstats")
if leaderstats then
local strength = leaderstats:FindFirstChild("Strength")
if strength then
strength.Value = strength.Value + 500
winner.Character.Humanoid.Health = 0
end
end
for i, player in ipairs(tournamentPlayers) do
if player == winner then
table.remove(tournamentPlayers, i)
break
end
end
tournamentActive = false
elseif #tournamentPlayers == 0 then
tournamentActive = false
end
wait(1)
end
end
local function enableTournamentGui(player)
local playerGui = player:WaitForChild("PlayerGui")
local guiClone = tournamentGui:Clone()
guiClone.Enabled = true
guiClone.Parent = playerGui
local joinButton = guiClone:WaitForChild("Join")
local noButton = guiClone:WaitForChild("No")
local function onJoinClicked()
table.insert(tournamentPlayers, player)
player.Character:SetPrimaryPartCFrame(teleportSpawn.CFrame)
guiClone:Destroy()
-- Destroy all tools
for _, tool in pairs(player.Backpack:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
for _, tool in pairs(player.Character:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
end
local function onNoClicked()
guiClone:Destroy()
end
joinButton.MouseButton1Click:Connect(onJoinClicked)
noButton.MouseButton1Click:Connect(onNoClicked)
delay(10, function()
if guiClone.Parent then
guiClone:Destroy()
end
end)
end
local function startTournament()
tournamentActive = true
for _, player in pairs(Players:GetPlayers()) do
enableTournamentGui(player)
end
delay(10, function()
if #tournamentPlayers > 0 then
monitorTournament()
else
tournamentActive = false
end
end)
end
Players.PlayerRemoving:Connect(function(player)
for i = #tournamentPlayers, 1, -1 do
if tournamentPlayers[i] == player then
table.remove(tournamentPlayers, i)
end
end
end)
while true do
if not tournamentActive then
startTournament()
end
wait(3) -- Wait for 60 seconds before starting the next tournament
end