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)
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)