Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- screenGui = Instance.new("ScreenGui")
- RFrame = Instance.new("Frame")
- RSlider = Instance.new("ImageButton")
- valueLabel = Instance.new("TextLabel")
- RSliderUICorner = Instance.new("UICorner")
- RFrameUICorner = Instance.new("UICorner")
- screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- RFrame.Size = UDim2.new(0, 300, 0, 10)
- RFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
- RFrame.AnchorPoint = Vector2.new(0.5, 0.5)
- RFrame.Parent = screenGui
- RFrame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- RFrameUICorner.CornerRadius = UDim.new(1, 0)
- RFrameUICorner.Parent = RFrame
- RSlider.Size = UDim2.new(0, 25, 0, 25)
- RSlider.Position = UDim2.new(0.035, 0, 0.5, 0)
- RSlider.AnchorPoint = Vector2.new(0.5, 0.5)
- RSlider.BackgroundColor3 = Color3.fromRGB(66, 170, 255)
- RSlider.Parent = RFrame
- RSlider.AutoButtonColor = false
- RSliderUICorner.CornerRadius = UDim.new(1, 0)
- RSliderUICorner.Parent = RSlider
- valueLabel.Size = UDim2.new(0, 50, 0, 50)
- valueLabel.Position = UDim2.new(1, 10, 0, 0)
- valueLabel.BackgroundColor3 = Color3.new(1, 1, 1)
- valueLabel.Text = "0"
- valueLabel.Parent = RFrame
- local function updateSlider_1(input)
- local position = math.clamp(input.Position.X - RFrame.AbsolutePosition.X, 0, RFrame.AbsoluteSize.X - RSlider.AbsoluteSize.X)
- RSlider.Position = UDim2.new(0, position + RSlider.AbsoluteSize.X / 2, 0.5, 0)
- local value = math.floor((position / (RFrame.AbsoluteSize.X - RSlider.AbsoluteSize.X)) * 255)
- valueLabel.Text = tostring(value)
- end
- local dragging = false
- RSlider.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- updateSlider_1(input)
- end
- end)
- RSlider.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = false
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
- updateSlider_1(input)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement