Roblox sliding UI does not work

Hello. I made a slide UI, but it doesn’t work.
Here is my code:

local button = script.Parent;
local isDown = false;
local outerLine = script.Parent.Parent.OuterLine;
local runService = game:GetService("RunService");
local player = game.Players.LocalPlayer;
local mouse = player:GetMouse();

function button_Down()
	isDown = false
end

function button_Up()
	isDown = true
end

function render_Step()
	if not isDown then return end;
	
	outerLine.Position = UDim2.new(0, math.clamp(mouse.X, 0, 483), 0, 0.486)
end

button.MouseButton1Down:Connect(button_Down)

button.MouseButton1Up:Connect(button_Up)

runService.RenderStepped:Connect(render_Step)

Any help?

1 Like

From what I see in your code the value of isDown never changes from false since button_Down() and button_Up() are never called.

You have a line in your RenderStepped function that prevents the code from going forward if isDown is false.

if not isDown then return end;

They are called at the bottom of the script

My bad. Didn’t see that you could scroll down.

1 Like

Are you trying to be able to drag it along the X axis?

I already know the reason, it is because Mouse.X returns the Position according to the Roblox window frame, but the frame that I move is parented to a frame object (which changes the way the object position changes accordingly), if I like move my mouse a lot to the left, it does drag that.
(I hope you get my point, I am not a native English speaker)

1 Like

I just did it! I just had to minus the AbsolutePosition’s X axis minus the frame’s position’s X axis.