Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how do i add a cool down onto these scripts after i shoot em?

Asked by 3 years ago

script one

script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)
    local FlukyGun = player.Character:FindFirstChild("[place holder]")
    if FlukyGun == nil then return end 
    local cframe = FlukyGun.Barrel.CFrame
    local bullet = game.ReplicatedStorage.[place holder]:Clone()
    bullet.Parent = script.Parent
    bullet.CFrame = cframe

    bullet.Parent = script.Parent
    bullet.CFrame = cframe
    bullet.Velocity = LookAt*360
    game.Debris:AddItem(bullet,3)
end)

script two

script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)
    local FlukyGun = player.Backpack:FindFirstChild("[place holder]") or player.Character:FindFirstChild("[place holder]")
    local cframe = FlukyGun.Barrel.CFrame
    local bullet = game.ReplicatedStorage.[place holder]:Clone()
    bullet.Parent = script.Parent
    bullet.CFrame = cframe
    bullet.Velocity = LookAt*360
    local fly = Instance.new("BodyForce",bullet)
    fly.Force = Vector3.new(0,bullet:GetMass()*180,0)
    game.Debris:AddItem(bullet,10)
        wait(2)
        bullet:remove()
    end)

i may just be dumb but i dont know how to add a cool down lol

0
ill check this in the mornin' steel_apples 58 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

What you can do is add a debounce. Example:

local debounce = false

if debounce == false then
    print("Debounce is false, continue")
    -- Code
else
    print("Debounce is true, do not continue")
end

1
You can simplify that greatly: if debounce == true then return end DetectiveRaie 193 — 3y
0
I did not know that. User#41156 0 — 3y
Ad

Answer this question