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
01 | local touching = false |
02 |
03 |
04 | script.Parent.MouseButton 1 Click: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 )) |
12 | end ) |
13 | script.Parent.MouseButton 1 Up:Connect( function () |
14 | touching = false |
15 | end ) |
What could i do to fix this problem?
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
1 | script.Parent.MouseButton 1 Click:Connect( function () |
to
1 | script.Parent.MouseButton 1 Down:Connect( function () |
should do the trick. Hope I helped!