How would I edit a horizontal slider to a vertical one?

I’m making a slider for a vehicle and I want to clone this one into a seperate gui.
slider
I want to change it into a vertical (up/down) slider but I’m not sure how to edit the script or the slider GUI (scale, offset, etc…).
EDIT: The closest i’ve gotten to making it work is just rotating the slider, but it only seems to slide when i move my mouse left/right.

Here’s the script (it’s a modified version of an existing one)

local MouseBeingHeldDown = false
local UserInputService = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local btn = script.Parent.Bar.Button
local originalPos = btn.Position
local slider = script.Parent.Bar

local padding = 0
local leftBound = padding
local rightBound = slider.AbsoluteSize.X - padding

script.Parent.Parent.ValTXT.Text = script.Parent.Percent.Value

function change_value(value)
	local new_value = math.floor(value * 100) / 100
	return new_value
end
btn.MouseButton1Down:Connect(function()
	MouseBeingHeldDown = true	
	repeat
		btn.Position = UDim2.new(
			UDim.new(0, math.clamp(
				mouse.X - slider.AbsolutePosition.X,
				leftBound, rightBound
				)),
			originalPos.Y
		)
		local percent_small = btn.Position.X.Offset/rightBound
		local percent_rounded = (math.floor(change_value(percent_small)*75))+16
		-----text stuff
		script.Parent.Parent.ValTXT.Text = percent_rounded
		---------------
		script.Parent.Percent.Value = percent_rounded
		workspace.CurrentCamera.FieldOfView = percent_rounded
		task.wait()
	until MouseBeingHeldDown == false
end)
btn.MouseButton1Up:Connect(function()
	MouseBeingHeldDown = false
end)
script.Parent.MouseLeave:Connect(function()
	MouseBeingHeldDown = false
end)

What should I change?

Try change mouse.X to mouse.Y

Doing that seems to make the slider stuck on the top end.

Yes because mouse.Y is smaller than mouse.X try mouse.Y*2

I almost have it working now, just changed it to mouse.Y*3 since mouse.Y*2 didn’t work. The slider is kinda offset from the mouse tho.

or try change this, it will be better:

local rightBound = slider.AbsoluteSize.Y - padding

and in math.clamp is this (mouse.Y - slider.AbsolutePosition.Y,leftBound,rightBound)

1 Like

It works now! Thanks for helping (i also did some other modifications to fix the offset)