So i was creating a slider for the volume setting in my game, and when testin i noticed my slider goes over the bacground frame. I have no idea why it’s happening.
Here the code:
local Mouse = game.Players.LocalPlayer:GetMouse()
local Slider = script.Parent
local Fill = script.Parent.Fill
local Trigger = script.Parent.Trigger
local function UpdateSlider()
local output = (Mouse.X-Slider.AbsolutePosition.X)/Slider.AbsoluteSize.X
Fill.Size = UDim2.fromScale(output,1)
end
local sliderActivated = false
function ActivateSlider()
sliderActivated = true
while sliderActivated do
UpdateSlider()
task.wait()
end
end
Trigger.MouseButton1Down:Connect(ActivateSlider)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
sliderActivated = false
end
end)
Slider Video:
GUI structure