I need to know the answer to this question as soon as possible. Read carefully!!! Here is the code:
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)
--1
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = Precent*100
--2
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Dragging = false
end
end)
I want a script instead of an element between 1 and 2, which after passing the GUI to the end removes the entire GUI. I tried to do it, but it failed. If you need to type a slider position, write "XYZ" .
