local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 5
while true do
t = 5
repeat
t = t-5
s.Value = "Get Ready.. "..t
wait(5)
until t == 0
s.Value = "Get Ready.."
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = ""..mapselect[i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
local num = math.random(1,32)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=130
repeat
t = t-1
s.Value = t.." seconds left"
wait(1)
until t ==0 or vals.Winner.Value ~= ""
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
game.Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
else
s.Value = "No one has won!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
workspace[curmap]:Destroy()
end
Make the vals.Winner.Value be something like “Round ended, No one won!” so it will probs work.
that didnt work, it automatically ends the round when nobody dies, even if they are doing the obby.
if #ingame == 0 then s.Value = "No one has won!" end
im still trying to learn lua, where do i put that line in?
local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 5
while true do
t = 5
repeat
t = t-5
s.Value = "Get Ready.. "..t
wait(5)
until t == 0
s.Value = "Get Ready.."
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = ""..mapselect[i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
local num = math.random(1,32)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=130
repeat
t = t-1
s.Value = t.." seconds left"
wait(1)
until t ==0 or vals.Winner.Value ~= ""
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
game.Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
else
s.Value = "Round ended, everyone has ran out of time!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
workspace[curmap]:Destroy()
end
if #ingame == 0 then s.Value = "No one has won!" end
Inside the repeat until where you do t = t - 1
it broke the ui, send the entire code because idk what im doing.
local ingame = workspace.Ingame:GetChildren()
repeat
if #ingame == 0 then vals.Winner.Value = "No winner!" end
t = t-1
s.Value = t.." seconds left"
wait(1)
until t ==0 or vals.Winner.Value ~= ""
local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 5
while true do
t = 5
repeat
t = t-5
s.Value = "Get Ready.. "..t
wait(5)
until t == 0
s.Value = "Get Ready.."
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = ""..mapselect[i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
local num = math.random(1,32)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=130
local ingame = workspace.Ingame:GetChildren()
repeat
ingame = workspace.Ingame:GetChildren()
if #ingame == 0 then vals.Winner.Value = "No winner!" end
t = t-1
s.Value = t.." seconds left"
wait(1)
until t ==0 or vals.Winner.Value ~= ""
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
game.Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
else
s.Value = "Round ended, everyone has ran out of time!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
workspace[curmap]:Destroy()
end
if #ingame == 0 then s.Value = "No one has won!" end
thanks!
that actually didnt work, are you sure the code is correct? the game stops working once everyone dies.
it broke the gui script
What I suggest you to do, is create another script for listening when player is added, character is added, and then when humanoid is dead. When a humanoid is dead, fire a bindableevent to your minigame script that removes the player from a table which has the Playing players, and then after removing, check if the #PlatyingPlayers is equal to 0, if it is then reset the round.
Make a string value through a script and put it inside the player in the round.(I’m naming it contestants)
Now type this script.
local availablePlayers = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player:FindFirstChild("contestants") then
table.insert(availablePlayers, player)
end
end
Next insert another string value this could be anywhere.
local string = Instance.new("StringValue")
string.Value = #availablePlayers
After that type this script
if #availablePlayers == 0 then
break -- this will break the whle script.
end
Note while doing the break script make sure you have a while wait() do to repeat the script.
I have another script too but I don’t know this will work
if s.Value == "No one has won!" then
break
end
Here also make sure you have a while wait() do
These two scripts have worked for me.