I’ve currently been trying to script a private game teleporter for my game that I’m working on, while scripting it I ran across an issue, I have an IntValue called QueueOnePlayerNum, which should reflect the amount of players in the first Queue, if the value is greater than or equal 4, then I wrote a function which plays if the value is greater than four, the function itself is working fine however my issues lies in that it only checks the value once, so as a test I set the value of QueueOnePlayerNum to 4 and the countdown function I wrote ran, however when I started the value out as 0, and then changed it to 4 after a couple seconds, nothing happened, I’ve only been using roblox studio for 3 months so I’m not sure what my problem is.
–local TS = game:GetService(“TeleportService”)
local QueueOneScreen = game.Workspace.QueueOne.QueueOneScreen.ScreenOne.ScreenOneGui.ScreenOneLabel
–local QueueOnePlayerNum = game.Workspace.QueueOne.QueueOnePlayerNum
local playersinqueueone = {}
local count = 30
local regionPart = workspace.QueueOne.QueueOneZone
local pos1, pos2 = (regionPart.Position - (regionPart.Size/2)), (regionPart.Position + (regionPart.Size/2))
local region = Region3.new(pos1,pos2)
local function countdown()
count = 30
local tracker = game.Workspace.QueueOne.QueueOnePlayerNum.Value
while tracker >=4 and count > 0 do
local tracker = game.Workspace.QueueOne.QueueOnePlayerNum.Value
if count >= 10 then
QueueOneScreen.Text = "00:"..count
else
QueueOneScreen.Text = "00:0"..count
end
count = count - 1
wait(1)
end
if count <= 0 then
QueueOneScreen.Text = “Teleporting…”
wait(1)
QueueOneScreen.Text = "Resetting.."
wait(1)
QueueOneScreen.Text = "00:30"
else
QueueOneScreen = "00:30"
end
end
while true do
local tracker = game.Workspace.QueueOne.QueueOnePlayerNum.Value
if tracker >= 4 then
countdown()
end
wait(0.25)
end
Examples:
Function not running even after changing the value
Function runs if value is set to greater than 4 before the game actually is run
Note: The script isn’t finished ignore the region3 part, I’m currently trying to figure out an efficient way to detect when a player leaves the region3 so it’s unfinished