You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Im making a slider for a music panel im making and i want it to not be wonky on a surface gui -
What is the issue? Include screenshots / videos if possible!
its wonky if its on a surfacegui but not on a screen gui -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried doing an offset to scale conversion but it didnt work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--//
local sliderButton = script.Parent
local sliderFrame = sliderButton.MovingFrame
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local snapAmount = .1
local pixelsFromEdge = .01
local movingSlider = false
sliderButton.MouseButton1Down:Connect(function()
movingSlider = true
end)
sliderButton.MouseButton1Up:Connect(function()
movingSlider = false
end)
mouse.Button1Up:Connect(function()
movingSlider = false
end)
mouse.Move:Connect(function()
if movingSlider then
local xOffset = math.floor((mouse.X - sliderButton.AbsolutePosition.X) / snapAmount + 0.5) * snapAmount
local xOffsetClamped = math.clamp(xOffset, pixelsFromEdge, sliderButton.AbsoluteSize.X - pixelsFromEdge)
local sliderPosNew = UDim2.new(0, xOffsetClamped, 0.5)
local roundedAbsSize = math.floor(sliderFrame.AbsoluteSize.X / snapAmount) * snapAmount
local roundedOffsetClamped = math.floor(xOffsetClamped / snapAmount) * snapAmount
local sliderValue = math.floor((roundedOffsetClamped / roundedAbsSize) * 100)
script.Parent.Parent.Change:FireServer(sliderValue, sliderPosNew, "Pitch")
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.