Well, the following script is supposed to work when you have the mouse pressed, but after I stop pressing it it still works the same and does not stop, I need it to stop working when the mouse is not held down and to work again when it is pressed
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local Button = script.Parent
Button.MouseButton1Down:Connect(function()
mouse.Move:Connect(function(Y)
Button:TweenPosition(UDim2.new(0.5, 0, mouse.Y/mouse.ViewSizeY, 0), nil, nil, 0.01)
end)
end)
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local Button = script.Parent
local shouldMouseMove = true
Button.MouseButton1Down:Connect(function()
shouldMouseMove = true
mouse.Move:Connect(function(Y)
if not shouldMouseMove then return end
Button:TweenPosition(UDim2.new(0.5, 0, mouse.Y/mouse.ViewSizeY, 0), nil, nil, 0.01)
end)
end)
Button.MouseButton1Up:Connect(function()
shouldMouseMove = false
end)
Try this. I haven’t tested it out for myself, so if there are any errors, you can tell me.