This script can be spammed and it's annoying. When I try to add a cooldown to it, it breaks. I want it to at least wait 10 seconds before it can be shot again. Help please
Script:
Player = script.Parent.Parent
mouse = Player:GetMouse()
function onKeyDown(key)
local Key = key:lower()
if key == "z" and Player.Levelss.Level.Value >= 15 then
local x = Instance.new("Part")
x.BrickColor = BrickColor.new("White")
x.Material = "Neon"
x.CanCollide = false
x.Transparency = 0.6
x.Size = Vector3.new(10,10,10)
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Shape = "Ball"
local fd = script.fireDamage:clone()
fd.Parent = x
local a = Instance.new("Sound")
a.SoundId = "http://www.roblox.com/asset/?id=260430117"
a.Parent = x
a.Volume = 2
a:play()
local y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(math.huge ,math.huge ,math.huge)
y.velocity = Player.Character.Torso.CFrame.lookVector*95
x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0 , -12)
x.Parent = Workspace
y.Parent = x
game.Debris:AddItem(x, 6)
end
end
mouse.KeyDown:connect(onKeyDown)
Thanks for reading

2 comments
Thank you! I know that I'm suppose to clean up my code, I just don't do it until I'm sure I've finished the script
No problem.