Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

ill check this in the mornin'

1 answer

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

2 comments

1

You can simplify that greatly: if debounce == true then return end

0

I did not know that.

This discussion is preserved as it was. New answers, comments, and votes are closed.