Advertisement
MaxproGlitcher

code pour balancer le volume en %

Mar 6th, 2023 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. game:GetService("StarterGui"):SetCore("SendNotification",{
  2. Title = "Volume Script",
  3. Text = "Script a été executer",
  4. Icon = "rbxassetid://11823384169",
  5. Duration = 15
  6. })
  7. if not game:IsLoaded() then game.Loaded:Wait() end
  8.  
  9. local plr = game.Players.LocalPlayer
  10. local m = plr:GetMouse()
  11. local us = game:GetService("UserInputService")
  12.  
  13. local function fiximage(id)
  14. return string.format("rbxthumb://type=Asset&id=%s&w=420&h=420",tonumber(id))
  15. end
  16.  
  17. local rblxgui = game.CoreGui:WaitForChild("RobloxGui")
  18. local shield = rblxgui:WaitForChild("SettingsShield"):WaitForChild("SettingsShield")
  19. local pageview = shield:WaitForChild("MenuContainer"):WaitForChild("PageViewClipper"):WaitForChild("PageView"):WaitForChild("PageViewInnerFrame")
  20. local volsound = rblxgui:WaitForChild("Sounds"):WaitForChild("VolumeChangeSound")
  21.  
  22. local settings = pageview:FindFirstChild("Page")
  23.  
  24. if not settings then
  25. local addedcon
  26. addedcon = pageview.ChildAdded:Connect(function(page)
  27. if page.Name == "Page" then
  28. settings = page
  29. addedcon:Disconnect()
  30. end
  31. end)
  32.  
  33. repeat task.wait() until settings
  34. end
  35.  
  36. local volume = settings:WaitForChild("VolumeFrame")
  37. volume:WaitForChild("Slider"):Destroy()
  38.  
  39. local slider = Instance.new("Frame")
  40. slider.AnchorPoint = Vector2.new(1,0.5)
  41. slider.BackgroundTransparency = 1
  42. slider.Position = UDim2.new(1,0,0.5,0)
  43. slider.Size = UDim2.new(0.6,0,1,0)
  44. slider.Name = "Slider"
  45.  
  46. local bar = Instance.new("ImageLabel",slider)
  47. bar.AnchorPoint = Vector2.new(0.5,0.5)
  48. bar.BackgroundTransparency = 1
  49. bar.Position = UDim2.new(0.5,0,0.5,0)
  50. bar.Size = UDim2.new(0.95,0,0.7,0)
  51. bar.ImageColor3 = Color3.fromRGB(78,84,96)
  52. bar.Image = fiximage(6755657364)
  53. bar.ScaleType = Enum.ScaleType.Slice
  54. bar.SliceCenter = Rect.new(210,210,210,210)
  55.  
  56. local fill = bar:Clone()
  57. fill.AnchorPoint = Vector2.new(0,0)
  58. fill.ImageColor3 = Color3.fromRGB(0,162,255)
  59. fill.Position = UDim2.new(0,0,0,0)
  60. fill.Size = UDim2.new(1,0,1,0)
  61. fill.Parent = bar
  62.  
  63. local gradient = Instance.new("UIGradient",fill)
  64. gradient.Color = ColorSequence.new(Color3.fromRGB(135,200,200))
  65. gradient.Transparency = NumberSequence.new({
  66. NumberSequenceKeypoint.new(0,0),
  67. NumberSequenceKeypoint.new(0.9999,0),
  68. NumberSequenceKeypoint.new(1,1)
  69. })
  70.  
  71. local button = Instance.new("TextButton",slider)
  72. button.ZIndex = 10
  73. button.BackgroundTransparency = 1
  74. button.Size = UDim2.new(1,0,1,0)
  75. button.Font = Enum.Font.SourceSans
  76. button.TextColor3 = Color3.fromRGB(255,255,255)
  77. button.TextSize = 26
  78.  
  79. local uset = UserSettings():GetService("UserGameSettings")
  80. local roundamount = 5
  81.  
  82. local oldval = uset.MasterVolume
  83. function update(percent)
  84. local trueround = roundamount/100
  85. local p = math.round(percent/trueround)*trueround
  86.  
  87. gradient.Offset = Vector2.new(p-1,0)
  88. uset.MasterVolume = p
  89. button.Text = math.round(p*100) .."%"
  90.  
  91. local diff = uset.MasterVolume - oldval
  92.  
  93. if diff ~= 0 then
  94. volsound:Play()
  95. end
  96. oldval = uset.MasterVolume
  97. end
  98.  
  99. function setslider()
  100. local abpos = bar.AbsolutePosition.X
  101. local absize = bar.AbsoluteSize.X
  102. local x = m.X
  103.  
  104. local p = math.clamp((x-abpos)/(absize),0,1)
  105. update(p)
  106. end
  107. update(uset.MasterVolume)
  108.  
  109. local holding = false
  110. button.MouseButton1Down:Connect(function()
  111. setslider()
  112. holding = true
  113. end)
  114.  
  115. us.InputEnded:Connect(function(key,pro)
  116. if key.UserInputType == Enum.UserInputType.MouseButton1 then
  117. holding = false
  118. end
  119. end)
  120.  
  121. volsound.Volume = 1
  122.  
  123. m.Move:Connect(function()
  124. if holding then
  125. setslider()
  126. end
  127. end)
  128.  
  129. slider.Parent = volume
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement