What should do: Player Join Queue > Timer starts from 30 to 0 > Another Code
What it does: Player Join Queue> Timer starts from 30 to 0 > Another Player Joins> Timer goes faster> Another code
Basically more players join the queue the more the timer goes fast and i’m searching a way to make it static and only subtracting 1/sec
Started = false
script.Parent.Players.Changed:Connect(function()
if script.Parent.Players.Value >= 1 then
Started = true
if Started == true then
repeat
script.Parent.Time.Value = script.Parent.Time.Value -1
Started = false
wait(1)
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
You’re running your loop every time the number of players changes.
You want to run your loop once.
One way might be to keep track of the previous number of players, and only start your timer if that changes:
local lastPlayers = 0
script.Parent.Players.Changed:Connect(function(newValue)
if lastPlayers == 0 and newValue > 0 then
repeat
script.Parent.Time.Value = script.Parent.Time.Value - 1
wait(1)
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
lastPlayers = newValue
end)
If you really want to make it go faster per player, I would change the “wait(1)” part, I would make it more like this:
Started = false
script.Parent.Players.Changed:Connect(function()
if script.Parent.Players.Value >= 1 then
Started = true
if Started == true then
repeat
script.Parent.Time.Value = script.Parent.Time.Value -1
Started = false
wait(2^-(script.Parent.Players.Value-1)) --This will make it so that it speeds up x2 for each new player after the first player.
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
This is how I would try to handle the problem (if you’re trying to make it speed up for however many players there are in the que). If it doesn’t work please tell me so I can re-look at it.
Actually when more than one player joins the queue the repeat loop starts more time and make it go 30-29-28-27 in like 1Sec, i’m searching for something that make the repeat loop start when ther is 1 player and does not start again
if script.Parent.Players.Value >= 1 then
if Started == false then
Started = true
repeat
script.Parent.Time.Value = script.Parent.Time.Value -1
wait(1)
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
else
Started = false
end
Started = false
script.Parent.Players.Changed:Connect(function()
if script.Parent.Players.Value >= 1 then
if Started == false then
Started = true
repeat
script.Parent.Time.Value = script.Parent.Time.Value -1
wait(1)
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
else
Started = false
end
Not working but i guess is because i have copied it wrong, here is the full script
Actually when another player joins it fires the teleport
local function cancel()
script.Parent.Time.Value = 30
end
Started = false
script.Parent.Players.Changed:Connect(function()
if script.Parent.Players.Value >= 1 then
if Started == false then
Started = true
repeat
script.Parent.Time.Value = script.Parent.Time.Value -1
wait(1)
until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
end
local tp = game:GetService("TeleportService")
local server = tp:ReserveServer(5496511414)
for i,v in pairs(script.Parent.Waiting:GetChildren()) do
if game.Players:FindFirstChild(v.Name) then
local Players = game:GetService("Players")
print("For now working...")
local plr = Players:FindFirstChild(v.Name)
print(plr)
print("Teleport ", plr, "To ", server )
tp:TeleportToPrivateServer(5496511414, server, {plr})
v:Destroy()
end
end
cancel()
else
Started = false
cancel()
end
end)