How can I fire a function repeteadly while mousebutton1 is holding down, and stop it when it stops to be holden?
I've tried a few thing, none working.
Sorry about the grammar mistakes :P
How can I fire a function repeteadly while mousebutton1 is holding down, and stop it when it stops to be holden?
I've tried a few thing, none working.
Sorry about the grammar mistakes :P
First of all, make sure you're using a Local Script.
This code should work:
local mouse = game.Players.LocalPlayer:GetMouse()
local mousdwn = false
Mouse.Button1Down:connect(function()
mousdwn = true
spawn(function() Mouse.Button1Up:wait() mousdwn = false end)
while mousdwn do
-- recurring code
wait()
end
end)
EDIT: Almost gave you the loop of death. :P
This discussion is preserved as it was. New answers, comments, and votes are closed.