Hi, I am making an Automatic Gun and you can click faster than the actual fire rate. Does anyone know how to fix it
script.Parent.Activated:Connect(function()
holding = true
while holding == true do
wait(0.1)
script.Parent.RemoteEvent:FireServer(Mouse.Hit.p)
end
end)
What are you trying to accomplish? Can you give an example of what you are trying to do?
If you have an autoclicker you can shoot the gun really fast but i dont want that because it goes faster than when you hold down the mouse
Just add a debounce to the script
local db = false
script.Parent.Activated:Connect(function()
holding = true
while holding == true and not db do
db = true
task.wait(0.1)
script.Parent.RemoteEvent:FireServer(Mouse.Hit.p)
end
end)
You could always track the last time the gun was shot and then check if that current time - last time is above the fire rate before allowing the player to fire.
Assuming your firerate is 0.1, It would look something along these lines:
local lastShot = 0
script.Parent.Activated:Connect(function()
holding = true
if (os.clock() - lastShot) >= 0.1 then
while holding == true do
wait(0.1)
script.Parent.RemoteEvent:FireServer(Mouse.Hit.p)
lastShot = os.clock()
end
end
end)
Thank you it now works how it should
I just had to edit the script and set the Debounce to false after task wait
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.