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

Gatling gun with cooldown not working?

Asked by 2 years ago

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)
0
i will re code it Deadx_scripts -2 — 2y
0
Explain what you want to do, I can't understand. SuperPuiu 497 — 2y
0
so do this: Deadx_scripts -2 — 2y
0
? imnotaguest1121 362 — 2y
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, Deadx_scripts -2 — 2y

1 answer

Log in to vote
-1
Answered by 2 years ago
Edited 2 years ago

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)

0
What? imnotaguest1121 362 — 2y
0
What? imnotaguest1121 362 — 2y
Ad

Answer this question