Just experimenting on a simulator type of game using XP and Levels, i'm trying to make it so you click to generate XP, but There is no Cooldown, EVEN when i use the cooldown Debounce. This is a regular script on a gear.
Basically i need a weapon that Generates experience with a Cooldown
amnt = math.random(1,100) --Generator
debouce = true
function onActivated()
if debouce == true then
debouce = false
local h = script.Parent.Parent:FindFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:FindFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:FindFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:FindFirstChild("EXP")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
end
end
wait(1) --Supposed to be the cooldown
debouce = true
end
script.Parent.Activated:Connect(onActivated) --Activation
The thing is, the cooldown wont work, it will work fine once, but spam click and it wont work anymore
UPDATE:
Turns out i needed to move the Wait(1) and Debouce = true 7 lines up lol, (6 if you dont include the line of nothing)
