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

How would I stop this script from glitching out when I spam it?

Asked by 5 years ago
local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

local camera = workspace.CurrentCamera







mouse.Button2Down:Connect(function()

for i = 1, 10 do

wait()

camera.FieldOfView = camera.FieldOfView - 3

end

end)



mouse.Button2Up:Connect(function()

for i = 1,10 do

wait()

camera.FieldOfView = camera.FieldOfView + 3

end

end)

Basically, spamming the left button on your mouse makes the animation glitch out a bit when zooming in and out, anyone know how to counter this? I tried with a wait loop but it does not work.

0
Maybe wait until the FieldOfView is to the point where you want it to be, and then allow the players to put their FieldOfView back after they lift up a key? DemonEyee 55 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Use Debounce. It helps prevent spamming in your functions. https://developer.roblox.com/articles/Debounce

0
It's not that simple. I need to store that the player tried to zoom out. And that is just not needed, I know there is a mich more simple way than this. Thesquid13 301 — 5y
Ad

Answer this question