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 4 years ago

script one

01script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)
02    local FlukyGun = player.Character:FindFirstChild("[place holder]")
03    if FlukyGun == nil then return end
04    local cframe = FlukyGun.Barrel.CFrame
05    local bullet = game.ReplicatedStorage.[place holder]:Clone()
06    bullet.Parent = script.Parent
07    bullet.CFrame = cframe
08 
09    bullet.Parent = script.Parent
10    bullet.CFrame = cframe
11    bullet.Velocity = LookAt*360
12    game.Debris:AddItem(bullet,3)
13end)

script two

01script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)
02    local FlukyGun = player.Backpack:FindFirstChild("[place holder]") or player.Character:FindFirstChild("[place holder]")
03    local cframe = FlukyGun.Barrel.CFrame
04    local bullet = game.ReplicatedStorage.[place holder]:Clone()
05    bullet.Parent = script.Parent
06    bullet.CFrame = cframe
07    bullet.Velocity = LookAt*360
08    local fly = Instance.new("BodyForce",bullet)
09    fly.Force = Vector3.new(0,bullet:GetMass()*180,0)
10    game.Debris:AddItem(bullet,10)
11        wait(2)
12        bullet:remove()
13    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 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

What you can do is add a debounce. Example:

1local debounce = false
2 
3if debounce == false then
4    print("Debounce is false, continue")
5    -- Code
6else
7    print("Debounce is true, do not continue")
8end
1
You can simplify that greatly: if debounce == true then return end DetectiveRaie 193 — 4y
0
I did not know that. User#41156 0 — 4y
Ad

Answer this question