So, this is basically a demonstration of what was said in the comments: Using a loop and MouseButton1Up.
Loops cause lag, so you could instead make an event and a BoolValue. I will cover this after the loop.
Loop
This is pretty simple, I think you will be able to understand it.
local debounce = false
local p = script.Parent
p.MouseButton1Down:connect(function()
debounce = true
end)
p.MouseButton1Up:connect(function()
debounce = false
end)
while wait() do
if debounce == true then
else
end
end
Event
This is a bit more complicated. You need to have a BoolValue inside the script, which detects whether the mouse is down.
There is a changed event in the same script, which basically changes everything.
local val = script.BoolValue
local p = script.Parent
p.MouseButton1Down:connect(function()
val.Value = true
end)
p.MouseButton1Up:connect(function()
val.Value = false
end)
val.Changed:connect(function()
if val.Value == true then
elseif val.Value == false then
end
end)
Hopefully I helped! Tell me in the comments if you need more.
~TDP
6 comments
Just loop until it detects MouseButton1Up.
good idea
THANK YOU
Or instead of looping you can write
script.Parent.MouseButton1Up:wait(), unless of course a loop is necessary for something you are processing.loops cause lag. I hate loops.
it only causes lag if you never end it.