Gui Slider Math?

Hello,

local e = false
script.Parent.MouseEnter:Connect(function()
	e = true
end)
script.Parent.MouseLeave:Connect(function()
	e = false
end)
local mou = game.Players.LocalPlayer:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function()
	if e==true then
		script.Parent.Position=UDim2.new(0,math.clamp(mou.X-script.Parent.AbsolutePosition.X,0,script.Parent.AbsoluteSize.X),0,0)
	end
end)

Math taken from: Gui Slider Math? - #6 by goldenstein64
- Br, iSyriux

You should be using the absolute size and position of the slider container, not the slider itself. Replace

math.clamp(mou.X-script.Parent.AbsolutePosition.X,0,script.Parent.AbsoluteSize.X)

with

math.clamp(mou.X-script.Parent.Parent.AbsolutePosition.X,0,script.Parent.Parent.AbsoluteSize.X)
1 Like