why do I get cash continous? I want a cooldown of 3 seconds. Only every 3 seconds should I get “Storage”. But it does random sometimes 5 secs nothing, somethings 10-20k per 3 secs.
3 ` local players=game:GetService(“Players”)
local active = false
script.Parent.TouchEnded:Connect(function()
active = false
end)
script.Parent.Touched:Connect(function(hit)
print(active)
active = true
if hit.Parent:FindFirstChild(“Humanoid”) ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local leader = player:WaitForChild(“leaderstats”)
local freefolder = player:WaitForChild(“test”)
local free = freefolder:WaitForChild(“FreeStorage”)
local storage = leader:WaitForChild(“Storage”)
if leader and freefolder and free and storage then
while wait(5) do
if active == true and player.test.FreeStorage.Value >= 0 then
leader.Storage.Value = leader.Storage.Value + 500
end
end
end
end
end)
local active = false
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if not active then
active = true
player.leaderstats.Storage.Value += 500
wait(3)
active = false
end
end
end)