I want to try making the gun script, automatic. But the problem is I don't know how to trigger it properly. Look down for examples.
Here's an brief-example of what I did so far:
mouse.Button1Down:connect(function() mouse.Button1Up:connect(function() game.ReplicatedStorage.ROBLOX_MP5FireEvent:FireServer(mouse.Hit.p) end)
Then here's my next one, it works fine but it shoots not automatic but pistol type. Where you have to spam click.
mouse.Button1Down:connect(function() game.ReplicatedStorage.ROBLOX_MP5FireEvent:FireServer(mouse.Hit.p) end)
Then what's the real fix to this?
Try to do with some variables. Like,
--This must be a LocalScript local FireRate = 0.1 local on = false local PL = game.Players.LocalPlayer local MS = PL:GetMouse() local MSPos = MS.Hit.p local SEvent = game.ReaplicatedStorage.ROBLOX_MP5FireEvent function Enable() on = true end function Disable() on = false end while on == true do wait(FireRate) SEvent:FireServer(MSPos) end
PM me on ROBLOX and say me if it works (Loulou1112)
What you can do is make a variable and use renderstepped.
local fire = false game:GetService.RunSerivce:RenderStepped:connect(function() if fire == true then game.ReplicatedStorage.ROBLOX_MP5FireEvent:FireServer(mouse.Hit.p) end end) mouse.Button1Down:connect(function() fire = true end) mouse.Button1Up:connect(function() fire = false end)
if this helped please accept :) ~KIHeros
Oh and if you want a firerate you can add a firerate variable
local fireRate = 0.2
--then make it wait the fireRate
if fire == true then wait(fireRate) game.ReplicatedStorage.ROBLOX_MP5FireEvent:FireServer(mouse.Hit.p) end