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:
01 | local mouse = game.Players.LocalPlayer:GetMouse() |
02 | local mousdwn = false |
03 |
04 | Mouse.Button 1 Down:connect( function () |
05 | mousdwn = true |
06 | spawn( function () Mouse.Button 1 Up:wait() mousdwn = false end ) |
07 | while mousdwn do |
08 | -- recurring code |
09 | wait() |
10 | end |
11 | end ) |
EDIT: Almost gave you the loop of death. :P
Marked as Duplicate by Shawnyg
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?