Need help on how to make a cooldown that shows the amount of seconds left

You can write your topic however you want, but you need to answer these questions:

  1. adding a cooldown to a command, with it returning only in seconds

  2. always showing up as 15.660430030 or something with a decimal point and a ton of other numbers

  3. can’t really find anything to solve this

handto UI with bindable events for a support system, integrated into basic admin, just can’t really understand like how to make it so it shows the cooldown in seconds, i’ve tried os.clock() and sort but just using tick() for at the moment

	
	Author:
	@TheFurryFish | (@RBLX_Fish)
	-----------------------------
	7/11/2015	
	
--]]

local Config
local children = script:GetChildren()
script = Instance.new("ModuleScript")
for _, child in pairs(children) do
	child.Parent = script
end

function StartModule(...)
	local tuple = {...}
	for i,v in pairs(tuple) do
		Config = v
	end

	local rFunction = Instance.new('RemoteFunction',game.ReplicatedStorage)
	rFunction.Name = ('HandTo_Sys')
	
	local uEvent = Instance.new('BindableEvent',game.ReplicatedStorage)
	uEvent.Name = ('UtilityFunction')
	spawn(function()
		game.ReplicatedStorage.ChildRemoved:connect(function(Item)
			if Item.Name == ('UtilityFunction') then
				if not game.ReplicatedStorage:FindFirstChild('UtilityFunction') then
					uEvent = Instance.new('BindableEvent',game.ReplicatedStorage) -- leave non-local
					uEvent.Name = ('UtilityFunction')
				end
			end
			if Item.Name == ('HandTo_Sys') then
				if not game.ReplicatedStorage:FindFirstChild('HandTo_Sys') then
					rFunction = Instance.new('RemoteFunction',game.ReplicatedStorage) -- leave non-local
					rFunction.Name = ('HandTo_Sys')
				end
			end
		end)
	end)	
	
	local Items = script:WaitForChild('Items')
	require(Items:WaitForChild('GiveGui'))
	local locScript = Items:WaitForChild('Main_Script')
	locScript.Parent = game.StarterGui:WaitForChild('GiveGui')
	local ConfigFolder = locScript:WaitForChild('Configuration')
	local gID = ConfigFolder:WaitForChild('GroupID')
	local rID = ConfigFolder:WaitForChild('RankID')
	local kBind = ConfigFolder:WaitForChild('KeyBind')
	gID.Value = Config['Group ID']
	rID.Value = Config['Group Rank']
	kBind.Value = Config['Key Bind']
	local Cooldown = {}
	function rFunction.OnServerInvoke(...)
		local Data = {...}
		local Player = Data[1]
		local PlrChar = Player.Character
		if Data[2] == 'support' then
			if Cooldown[Player.UserId] == nil then
				Cooldown[Player.UserId] = tick()
				uEvent:Fire(Player,"Support")
				uEvent:Fire(Player,"Logs",Player.Name..": Called for support!")
			else
				if tick() - Cooldown[Player.UserId] > 28 then
					uEvent:Fire(Player,"Support")
					uEvent:Fire(Player,"Logs",Player.Name..": Called for support!")
					Cooldown[Player.UserId] = tick()
				else
					return uEvent:Fire(Player,"Notice","Error","Please wait before calling for assistance again!")
				end
			end	
		elseif Data[2] == "notify" then
			uEvent:Fire(Player, "HintMsg","Player not found",Data[3].. " was not found. Make sure you're entering the username correctly.")
		elseif Data[2] == "Hint" then
			local Reply = uEvent:Fire(Player, 'HintMsg',Data[1],Data[2])
		elseif Data[2] == "Commands" then
			uEvent:Fire(Player, "Commands", nil)
		elseif Data[2] == ('HandTo') then
			if Data[3] ~= nil and game.Players:FindFirstChild(Data[3]) then
				local Reciever = game.Players:WaitForChild(Data[3])
				if PlrChar:FindFirstChild(Data[4]) then
					local Item = PlrChar:WaitForChild(Data[4])
					Item.Parent = Reciever.Backpack
					------------------
					uEvent:Fire(Player,"Logs",Player.Name..": Gave "..Item.Name.." to "..Reciever.Name)
					------------------
					uEvent:Fire(Player,'HintMsg',"Successfully gave item to "..Reciever.Name,'You gave '..Item.Name.. " to "..Reciever.Name)
					------------------
					uEvent:Fire(Reciever, 'HintMsg',"Utility System | "..Player.Name.." gave you an item",Player.Name.." gave you the item: '"..Item.Name.."'")
				end
				if Data[4] ~= nil and tostring(Data[3]) ~= nil then
					return 'You gave '..'"'..tostring(Data[4])..'" to '..tostring(Data[3])..''
				end
			end
		else
			return "Error - Data[2] is not specified correctly."
		end
	end
end

return StartModule[quote="jackson, post:1, topic:2704172, full:true, username:MACBO0KS"]
You can write your topic however you want, but you need to answer these questions:
1. adding a cooldown to a command, with it returning only in seconds

2. always showing up as 15.660430030 or something with a decimal point and a ton of other numbers

3. can't really find anything to solve this



```--[[
	
	Author:
	@TheFurryFish | (@RBLX_Fish)
	-----------------------------
	7/11/2015	
	
--]]

local Config
local children = script:GetChildren()
script = Instance.new("ModuleScript")
for _, child in pairs(children) do
	child.Parent = script
end

function StartModule(...)
	local tuple = {...}
	for i,v in pairs(tuple) do
		Config = v
	end

	local rFunction = Instance.new('RemoteFunction',game.ReplicatedStorage)
	rFunction.Name = ('HandTo_Sys')
	
	local uEvent = Instance.new('BindableEvent',game.ReplicatedStorage)
	uEvent.Name = ('UtilityFunction')
	spawn(function()
		game.ReplicatedStorage.ChildRemoved:connect(function(Item)
			if Item.Name == ('UtilityFunction') then
				if not game.ReplicatedStorage:FindFirstChild('UtilityFunction') then
					uEvent = Instance.new('BindableEvent',game.ReplicatedStorage) -- leave non-local
					uEvent.Name = ('UtilityFunction')
				end
			end
			if Item.Name == ('HandTo_Sys') then
				if not game.ReplicatedStorage:FindFirstChild('HandTo_Sys') then
					rFunction = Instance.new('RemoteFunction',game.ReplicatedStorage) -- leave non-local
					rFunction.Name = ('HandTo_Sys')
				end
			end
		end)
	end)	
	
	local Items = script:WaitForChild('Items')
	require(Items:WaitForChild('GiveGui'))
	local locScript = Items:WaitForChild('Main_Script')
	locScript.Parent = game.StarterGui:WaitForChild('GiveGui')
	local ConfigFolder = locScript:WaitForChild('Configuration')
	local gID = ConfigFolder:WaitForChild('GroupID')
	local rID = ConfigFolder:WaitForChild('RankID')
	local kBind = ConfigFolder:WaitForChild('KeyBind')
	gID.Value = Config['Group ID']
	rID.Value = Config['Group Rank']
	kBind.Value = Config['Key Bind']
	local Cooldown = {}
	function rFunction.OnServerInvoke(...)
		local Data = {...}
		local Player = Data[1]
		local PlrChar = Player.Character
		if Data[2] == 'support' then
			if Cooldown[Player.UserId] == nil then
				Cooldown[Player.UserId] = tick()
				uEvent:Fire(Player,"Support")
				uEvent:Fire(Player,"Logs",Player.Name..": Called for support!")
			else
				if tick() - Cooldown[Player.UserId] > 28 then
					uEvent:Fire(Player,"Support")
					uEvent:Fire(Player,"Logs",Player.Name..": Called for support!")
					Cooldown[Player.UserId] = tick()
				else
					return uEvent:Fire(Player,"Notice","Error","Please wait before calling for assistance again!")
				end
			end	
		elseif Data[2] == "notify" then
			uEvent:Fire(Player, "HintMsg","Player not found",Data[3].. " was not found. Make sure you're entering the username correctly.")
		elseif Data[2] == "Hint" then
			local Reply = uEvent:Fire(Player, 'HintMsg',Data[1],Data[2])
		elseif Data[2] == "Commands" then
			uEvent:Fire(Player, "Commands", nil)
		elseif Data[2] == ('HandTo') then
			if Data[3] ~= nil and game.Players:FindFirstChild(Data[3]) then
				local Reciever = game.Players:WaitForChild(Data[3])
				if PlrChar:FindFirstChild(Data[4]) then
					local Item = PlrChar:WaitForChild(Data[4])
					Item.Parent = Reciever.Backpack
					------------------
					uEvent:Fire(Player,"Logs",Player.Name..": Gave "..Item.Name.." to "..Reciever.Name)
					------------------
					uEvent:Fire(Player,'HintMsg',"Successfully gave item to "..Reciever.Name,'You gave '..Item.Name.. " to "..Reciever.Name)
					------------------
					uEvent:Fire(Reciever, 'HintMsg',"Utility System | "..Player.Name.." gave you an item",Player.Name.." gave you the item: '"..Item.Name.."'")
				end
				if Data[4] ~= nil and tostring(Data[3]) ~= nil then
					return 'You gave '..'"'..tostring(Data[4])..'" to '..tostring(Data[3])..''
				end
			end
		else
			return "Error - Data[2] is not specified correctly."
		end
	end
end

return StartModule’’’

Make a number or int value set the value go the amount of seconds the cooldown has and when the cooldown is active make the value lose 1 per second and then use runservice to always set the text to the int or number value

(Sorry if this was confusing i’m on mobile rn)

uhh could u explain this a bit further?

you can try to make a debounce system for the cooldown and by that you can show the second by the debounce var

1 Like

What I’m trying to say is you should make a number value set the value to amount of seconds you need, then you can use a for loop every second to subtract the value by 1 then you can keep updating the text using runservice or another loop

there’s not an easier way to do that? I’ll try that — but I thought there was an easier way involving os.clock() or something