local UIS = game:GetService("UserInputService") local runService = game:GetService("RunService") --local local player = game.Players.LocalPlayer local slider = script.Parent local sliderbar = script.Parent.Parent local Bckcolor = script.Parent.Parent.Color local held = false UIS.InputBegan:Connect(function(Input, Processed) if Input.UserInputType == Enum.UserInputType.MouseButton1 then held = true end end) UIS.InputEnded:Connect(function(Input, Processed) held = false end) runService.RenderStepped:Connect(function(delta) if held then local mousePos = UIS:GetMouseLocation().X local Position = mousePos - sliderbar.AbsolutePosition.X local step = (Position/sliderbar.AbsoluteSize.X) if step >= 0 and step <= 1 then Bckcolor.Size = UDim2.new(step,0,0,11) slider.Position = UDim2.new(step,0,-1,0) end end end)
Do a while true do when the held is true
For example
while held = true do --function here end
There is a RBXScriptSignal called Button2Down that comes with the mouse
game.Players.LocalPlayer:GetMouse().Button2Down:Connect(function() print("Player is holding down right click") end)
https://developer.roblox.com/en-us/api-reference/event/Mouse/Button2Down
local UIS = game:GetService("UserInputService") local runService = game:GetService("RunService") local SN = script.Parent.Parent.Parent.Parent.SoundNumber.Number local player = game.Players.LocalPlayer local slider = script.Parent local sliderbar = script.Parent.Parent local Bckcolor = script.Parent.Parent.Color local part = script.Parent.Parent.Parent.range local held = false UIS.InputBegan:Connect(function(Input, Processed) if Input.UserInputType == Enum.UserInputType.MouseButton1 then part.MouseEnter:Connect(function() slider.MouseButton1Down:Connect(function() held = true end) end) end end) UIS.InputEnded:Connect(function(Input, Processed) part.MouseLeave:Connect(function() slider.MouseButton1Up:Connect(function() held = false end) end) end) runService.RenderStepped:Connect(function(delta) if held then local mousePosX = UIS:GetMouseLocation().X local Position = mousePosX - sliderbar.AbsolutePosition.X local step = (Position/sliderbar.AbsoluteSize.X) local number = tonumber(string.format("%.2f",step))*100 if step >= 0 and step <= 1 then if number == 99 then SN.Text = 100 else SN.Text = number end Bckcolor.Size = UDim2.new(step,0,0,11) slider.Position = UDim2.new(step,0,-1,0) end end end)