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

Gatling gun with cooldown not working?

So I made a laser gun that shoots every 0.005 seconds (In roblox time) but the problem Is where the Local script doesn't shoot when your holding the mouse down

Local script:

local player = game.Players.LocalPlayer
local FireEvent = script.Parent:WaitForChild("FireEvent")
local mouse = player:GetMouse()
local debounce = false

mouse.Button1Down:Connect(function()
	if not debounce then
		debounce = true
		FireEvent:FireServer()
		print("The lasergun has shot a bullet")
		wait(0.005)
		debounce = false
	end
end)

5 comments

0

i will re code it

0

Explain what you want to do, I can't understand.

0

so do this:

0

?

0

local Gun = script.Parent local RS = game:GetService("ReplicatedStorage") local FireEvent = RS:WaitForChild("FireEvent") -- put it in repstorage local Repeat = true local player = game.Players.LocalPlayer Gun.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if Repeat == true then Repeat = false print("The lasergun has shot a bullet") FireEvent:FireServer(Gun.Handle.Position,

1 answer

so you need to send infomation to the server event so do this:

in a local script

local Gun = script.Parent local RS = game:GetService("ReplicatedStorage") local FireEvent = RS:WaitForChild("FireEvent") -- put it in repstorage local Repeat = true local player = game.Players.LocalPlayer

Gun.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if Repeat == true then Repeat = false print("The lasergun has shot a bullet") FireEvent:FireServer(Gun.Handle.Position, mouse.Hit.p) -- sends handle pos and mouse pos wait(0.05) Repeat = true end end) end)

2 comments

0

What?

0

What?

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