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
local touching = false script.Parent.MouseButton1Click:Connect(function() touching = true coroutine.resume(coroutine.create(function() repeat script.Parent.Parent.fire:FireServer("rotate","left") wait(0.1) until touching == false end)) end) script.Parent.MouseButton1Up:Connect(function() touching = false 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
script.Parent.MouseButton1Click:Connect(function()
to
script.Parent.MouseButton1Down:Connect(function()
should do the trick. Hope I helped!