How would i make this slider script be for surfaceguis?

So i have this slider script, however i want it to be for surface guis, help would be appreciated, thanks.

local mouse = game.Players.LocalPlayer:GetMouse()
local slider = script.Parent.Parent
local button = slider.SliderHitbox
local fill = slider.SliderInside
local opv = slider.Intensity

local currentcap = 0.2


fill.Size = UDim2.fromScale(opv.Value/currentcap,1)
button.Text = tostring(math.round(opv.Value*100))/10

if string.match(button.Text, ".") == true then
	print(button.Text)
else
	button.Text = button.Text.. ".0"
	print(button.Text)
end

local sla = false


function UpdateSlider()
	local op = (mouse.X-slider.AbsolutePosition.X)/slider.AbsoluteSize.X
	print(op)
	if op > currentcap then return end
	if op < 0.1 then return end
	opv.Value = op
	button.Text = tostring(math.round(op*100))/10
	fill.Size = UDim2.fromScale(op/currentcap,1)
end

function ActivateSlider()
	print("a")
	sla = true
	while sla do
		UpdateSlider()
		task.wait()
	end
end

button.MouseButton1Down:Connect(ActivateSlider)

game:GetService("UserInputService").InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		sla = false
	end
end)

Have you tried parenting the slider to a surfacegui?

Yes that works, but the slider still uses the position of the mouse compared to the screen, not where the slider actually is.