i try to make a cooldown for my fireball, when i try to spamming it, it does not have a cooldown. Help me please
this is the fireball script
local Character = Player.Character
Fireball.Position = Character.RightHand.Position
Fireball.Parent = workspace
local velocity = Instance.new("BodyVelocity", Fireball)
velocity.Velocity = CFrame.new(Fireball.Position, Mouse).LookVector * 50
Animation:Play()
debounce = true
Fireball.Touched:Connect(function(Touched)
if Touched:IsDescendantOf(Character) then return end
Fireball:Destroy()
if Touched.Parent:FindFirstChild("Humanoid") then
Touched.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
end
wait(3)
debounce = false
end)
end)
and this is the fireball activation script
local UIS = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local debounce = false
UIS.InputBegan:Connect(function(key, processed)
if processed or debounce then return end
if key.KeyCode == Enum.KeyCode.Q then
debounce = true
workspace.FireballScript.RemoteEvent:FireServer(mouse.Hit.Position)
end
wait(3)
debounce = false
end)
there is nothing error with the code

2 comments
where i should put the second end cause there is 2 if statement
roblox lua (unlike other languges) really does not care about where you indent so just add another one on the line that the end) is on