Hi there, I have a piano with tuning knobs that you can rotate to adjust a soung effect (e.g CompressorEffect). The issue is, is that the event mouse.Move
does not disconnect despite it being assigned a variable, and disconnected. I’ve tried everything, and even used inputEnded
to disconnect the function.
Script below:
for t,k in pairs(v) do
local connection
local connection2
local turnclone = panelclone['turn']:Clone()
turnclone.Name = k
turnclone.TextLabel.Text = k
turnclone.Visible = true
local btn = turnclone.ImageButton
turnclone.Parent = panelclone
connection2 = btn.MouseButton1Down:Connect(function()
connection = mouse.Move:Connect(function(x,y)
local differenceX = btn.AbsolutePosition.X - mouse.X
local differenceY = btn.AbsolutePosition.Y - mouse.Y
local angle = math.deg(math.atan(differenceY/differenceX))
btn.Rotation = angle
end)
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType.Name == 'MouseButton1' and connection then
connection:Disconnect()
connection2:Disconnect()
turnremote:FireServer(turnclone.Name,btn.Rotation)
end
end)
end