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

Detect if a textbutton is being held?

Asked by 5 years ago

Hello, im making a cannon script where you can control it from a gui, but there is a problem, when i want to rotate i made it so you can hold it and it keeps rotating but it just does it once I tried this

01local touching = false
02 
03 
04script.Parent.MouseButton1Click:Connect(function()
05    touching = true
06    coroutine.resume(coroutine.create(function()
07    repeat
08        script.Parent.Parent.fire:FireServer("rotate","left")
09        wait(0.1)
10    until touching == false
11    end))
12end)
13script.Parent.MouseButton1Up:Connect(function()
14    touching = false
15end)

What could i do to fix this problem?

1 answer

Log in to vote
1
Answered by 5 years ago

I think I have figured out your problem. You're using MouseButton1Click instead of MouseButton1Down. MouseButton1Click only fires when a mouse has completed a full left click (i.e. button down then button up). Changing

1script.Parent.MouseButton1Click:Connect(function()

to

1script.Parent.MouseButton1Down:Connect(function()

should do the trick. Hope I helped!

0
Oml i didn't notice that thanks maumaumaumaumaumua 628 — 5y
Ad

Answer this question