I want to create a script that makes a frame scroll by MouseWheelForward & MouseWheelBackwards, this frame that’s suppose to scroll is gonna determine the lighting and other stuff like that, a scrolling thing for settings basically. This is what i currently have:
You should never connect events inside of events, it always leads to memory leaks. Just remove the usage of MouseEnter and MouseLeave, and this script should work good enough.
Actually, you don’t. You’re moving it up and down by -0.375 scale. If you just change that to 0, then it should not move on the Y axis. Also remove FrameToDrag.Position.X.Scale in the UDim2.new’s, and then the slider should work fine.
FrameToDrag.MouseWheelForward:Connect(function()
FrameToDrag.Position += UDim2.new(0.1)
if FrameToDrag.Position.X.Scale < 0 then -- clamp position left
FrameToDrag.Position -= UDim2.new(FrameToDrag.Position.X.Scale)
end
end)
FrameToDrag.MouseWheelBackward:Connect(function()
FrameToDrag.Position += UDim2.new(-0.1)
if FrameToDrag.Position.X.Scale > 1 then -- clamp position right
FrameToDrag.Position -= UDim2.new(FrameToDrag.Position.X.Scale - 1)
end
end)