I’m making a slider for a vehicle and I want to clone this one into a seperate gui.
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?