I’ve made a slider that uses percentages it goes from 0 to 1,
now my question is how would i make it so it goes within a number range starting and ending with different numbers like percentages are like 0 - 100, and i wanna to make it where it starts off from 70 and end at 120
video i used
1 Like
–code
local UserInputService = game:GetService(“UserInputService”)
local gui = script.Parent
local slider = gui.Slider
local button = slider.Button
local box = gui.Box
local clicked = false
button.MouseButton1Down:Connect(function()
clicked = true
end)
button.MouseButton1Up:Connect(function()
clicked = false
end)
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
if clicked then
local location = UserInputService:GetMouseLocation()
local pos = location - slider.AbsolutePosition
local percent = math.clamp(pos.X/slider.AbsoluteSize.X,0,1)
button.Position = UDim2.new(percent,0,.661,0)
box.Text = percent
end
end
end)
box.FocusLost:Connect(function()
local numb = tonumber(box.Text)
if numb then
local percent = math.clamp(numb,0,1)
button.Position = UDim2.new(percent,0,.661,0)
box.Text = percent
end
end)
1 Like