Hello, so i make a Countdown when a player Join is creating a Folder with the player UserId and put in IntValue. Now the problem is I don’t know how to make that every second in all the userId folder that are in the server changes the value of -1
You Can Do It with A simple loop, but first you have to set the amount of time that you want for your count down for example:
local ServStorage = game.ServerStorage
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
-- Setup UserId Folder
local NewUserFolder = Instance.new("Folder")
NewUserFolder.Name = player.UserId
NewUserFolder.Parent = ServStorage:WaitForChild("StandCountdownPlayers")
-- Setup Timer Instance
local OpenStandTimer = Instance.new("IntValue")
-- Setup Timer Names
OpenStandTimer.Name = "OpenStandTimer"
-- Setup Timer Folder
OpenStandTimer.Parent = NewUserFolder
OpenStandTimer.Value = 3 -- the time of count down
local finish = false
while wait(1) do -- this loop will run every 1 sec
OpenStandTimer.Value = OpenStandTimer.Value - 1
if OpenStandTimer.Value == 0 then -- checks if the countdown is finnished
finish = true
break -- it will breaks the loop
end
end
if finish == true then
-- your action here
end
end)
Players.PlayerRemoving:Connect(function(player)
ServStorage.StandCountdownPlayers:WaitForChild(player.UserId):Destroy()
end)
@3MASTER9 Thx you, i modified you script and now is make what i need !
So for infomartion this is the script
--Timer System
while wait(1) do
if ServStorage.StandCountdownPlayers:FindFirstChild(player.UserId) then
if OpenStandTimer.Value > 0 then
OpenStandTimer.Value = OpenStandTimer.Value - 1
end
else
break -- it will breaks the loop
end
end