So I made a topic on this a few days ago and many people tried, but we were not able to solve the issue. (The old topic)
So basically I have this:
plrsGui.speechFrame.speech.MouseButton1Click:Connect(function()
if not deb2 then
deb2 = true
print("Clicked")
--scroll()
else
wait(1)
deb2 = false
end
end)
Clicked prints more than once, but a different amount every time! Please help!
The version you had in the old topic should be correct.
local deb2 = false
plrsGui.speechFrame.speech.MouseButton1Up:Connect(function()
if not deb2 then
deb2 = true
print("Clicked")
--scroll()
wait(2)
deb2 = false
end
end)
If it’s printing multiple times per click then there might be multiple functions connected to this one event.
Nope I guess I was just using the disconnect wrong last time I tried it because this time I got it to work, the reason it gets connected multiple times is because this is in a touched event! I honestly don’t know what I did different this time when it comes to disconnecting but it works so im not complaining. It’s working perfectly now!
For anybody that comes across this in the future, the problem is this is in a touched event so it gets hooked up multiple times, so each time you touch it you have to make sure there is no other connection, or disconnect the other connection, this is how I solved it:
local connection
invisWall.Touched:Connect(function(hit)
-- More code (not important for this)
if connection then
connection:Disconnect()
end
connection = plrsGui.speechFrame.speech.MouseButton1Up:Connect(function()
if not deb2 then
deb2 = true
scroll() -- Replace with your thing
wait(0.5)
deb2 = false
end
end)
end)