So i have a slider in game and the point of it is for players to be able to pick a number between 1 and 10. My issue is that the slider gives me a HUGE number from between 5.1312805581556188983 and 4.1333753849842871375. I have tried to convert that massive number to a real number but i had no real success.
How do i go about making the slider give me real outputs in increments of .50 (Ex: 1.00, 1.50, 2.00, Etc... up until 10.00) I also need it to clamp onto those increments in the slider.
Picture: https://gyazo.com/c43b0b2923b1e01e363a3fdf3a16e80c
Here is the code:
script.Parent.ImageButton.DragBegin:Connect(function()
game:GetService("RunService"):BindToRenderStep("DragSlider", Enum.RenderPriority.Camera.Value-1, function()
local p = script.Parent.ImageButton.Position
script.Parent.ImageButton.Position = UDim2.new(0.5, 0, 0, math.clamp(p.Y.Offset, 0, script.Parent.AbsoluteSize.Y))
end)
end)
script.Parent.ImageButton.DragStopped:Connect(function()
local p1 = script.Parent.AbsolutePosition.Y
local p2 = script.Parent.ImageButton.AbsolutePosition.Y
local p3 = script.Parent.ImageButton.Position.Y
local max = script.Parent.AbsoluteSize.Y
local v = math.clamp(5-(p2-p1)/max, 0, 10)
local sc = script.Parent.Screen.Data
script.Parent.Value.Value = v
print(script.Parent.Value.Value)
sc.Text = script.Parent.Value.Value
end)

2 comments
You can round to the nearest half with
math.floor(n*2)/2yes