I have a simple laser-pistol creating by ROBLOX (the one from the wiki) and I was wondering on how I would go about making it automatic without having to fire the RemoteEvent multiple time as that causes lag. I forgot to mention that I've already converted it to function with FE.
I've tried while loops and repeat loops but I can't for some reason make it work. Any suggestion?
A simple one would look like this:
(A local script inside a tool):
local FIRE_DELAY = 0.1 local Tool = script.Parent local active = false Tool.Activated:Connect(function() active = true end Tool.Deactivated:Connect(function() active = false end local function CanShoot() return active end local function Shoot() -- Shooting code goes here. end local lastFiredTime = tick() game:GetService("RunService").Stepped:Connect(function() local timeNow = tick() if CanShoot() then if timeNow - lastFiredTime > FIRE_DELAY then Shoot() lastFiredTime = timeNow end end end)