Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to replace the GUI slider script? Please FAST anwser me.

Asked by 3 years ago

I can't do that between lines 1 and 2 to create a script which, after leading the slider to the end of the bar, removes the entire GUI. If you need the final position of the GUI just write "XYZ".

local UserInputService = game:GetService("UserInputService")
local Dragging = false
script.Parent.TextButton.MouseButton1Down:Connect(function()
    Dragging = true
end)

UserInputService.InputChanged:Connect(function()
    if Dragging then
        local MousePos = UserInputService:GetMouseLocation()+Vector2.new(0,36)
        local RelPos = MousePos-script.Parent.AbsolutePosition
        local Precent = math.clamp(RelPos.X/script.Parent.AbsoluteSize.X,0,1)
        script.Parent.TextButton.Position = UDim2.new(Precent,0,0.5,0)
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = Precent*100
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        Dragging = false
    end
end)

Answer this question