Advertisement
im_a_user001

Script GUI Player

Jun 25th, 2024 (edited)
6,996
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.10 KB | Source Code | 1 0
  1. -- FPS AND HP DOESN'T WORK SORRY :( MIGHT BE SOLVED
  2. local UIS = game:GetService("UserInputService")
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local camera = workspace.CurrentCamera
  6.  
  7. -- Default values
  8. local defaultValues = {
  9.     SpeedChanger = 16,
  10.     JumboostChanger = 50,
  11.     GravityChanger = 196.2,
  12.     PlayerFov = 70,
  13.     HipHeight = 2,
  14.     FPS = 60,
  15.     ZOOM = 10,
  16.     HPMin = 100,
  17.     HPMax = 100
  18. }
  19.  
  20. -- Create the main GUI
  21. local ScreenGui = Instance.new("ScreenGui")
  22. ScreenGui.Parent = player:WaitForChild("PlayerGui")
  23. ScreenGui.Name = "SettingsGui"
  24.  
  25. -- Create a draggable frame
  26. local mainFrame = Instance.new("Frame")
  27. mainFrame.Size = UDim2.new(0, 350, 0, 600)
  28. mainFrame.Position = UDim2.new(0.5, -175, 0.5, -300)
  29. mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  30. mainFrame.BorderSizePixel = 0
  31. mainFrame.Parent = ScreenGui
  32.  
  33. -- Make the frame draggable
  34. local dragging = false
  35. local dragInput, mousePos, framePos
  36.  
  37. mainFrame.InputBegan:Connect(function(input)
  38.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  39.         dragging = true
  40.         mousePos = input.Position
  41.         framePos = mainFrame.Position
  42.        
  43.         input.Changed:Connect(function()
  44.             if input.UserInputState == Enum.UserInputState.End then
  45.                 dragging = false
  46.             end
  47.         end)
  48.     end
  49. end)
  50.  
  51. mainFrame.InputChanged:Connect(function(input)
  52.     if input.UserInputType == Enum.UserInputType.MouseMovement then
  53.         dragInput = input
  54.     end
  55. end)
  56.  
  57. UIS.InputChanged:Connect(function(input)
  58.     if input == dragInput and dragging then
  59.         local delta = input.Position - mousePos
  60.         mainFrame.Position = UDim2.new(framePos.X.Scale, framePos.X.Offset + delta.X, framePos.Y.Scale, framePos.Y.Offset + delta.Y)
  61.     end
  62. end)
  63.  
  64. -- Create a close button
  65. local closeButton = Instance.new("TextButton")
  66. closeButton.Size = UDim2.new(0, 30, 0, 30)
  67. closeButton.Position = UDim2.new(1, -35, 0, 5)
  68. closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  69. closeButton.Text = "X"
  70. closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  71. closeButton.TextSize = 18
  72. closeButton.Parent = mainFrame
  73.  
  74. closeButton.MouseButton1Click:Connect(function()
  75.     mainFrame:TweenSizeAndPosition(UDim2.new(0, 0, 0, 0), UDim2.new(0.5, 0, 0.5, 0), "Out", "Quad", 0.5, true, function()
  76.         ScreenGui:Destroy()
  77.     end)
  78. end)
  79.  
  80. -- Create a minimize button
  81. local minimizeButton = Instance.new("TextButton")
  82. minimizeButton.Size = UDim2.new(0, 30, 0, 30)
  83. minimizeButton.Position = UDim2.new(1, -70, 0, 5)
  84. minimizeButton.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
  85. minimizeButton.Text = "-"
  86. minimizeButton.TextColor3 = Color3.fromRGB(0, 0, 0)
  87. minimizeButton.TextSize = 18
  88. minimizeButton.Parent = mainFrame
  89.  
  90. local minimized = false
  91.  
  92. minimizeButton.MouseButton1Click:Connect(function()
  93.     if minimized then
  94.         mainFrame:TweenSize(UDim2.new(0, 350, 0, 600), "Out", "Quad", 0.5, true)
  95.         for _, frame in pairs(mainFrame:GetChildren()) do
  96.             if frame:IsA("Frame") then
  97.                 frame.Visible = true
  98.             end
  99.         end
  100.     else
  101.         mainFrame:TweenSize(UDim2.new(0, 350, 0, 50), "Out", "Quad", 0.5, true)
  102.         for _, frame in pairs(mainFrame:GetChildren()) do
  103.             if frame:IsA("Frame") then
  104.                 frame.Visible = false
  105.             end
  106.         end
  107.     end
  108.     minimized = not minimized
  109. end)
  110.  
  111. -- Create settings frames
  112. local function createSettingFrame(name, position)
  113.     local frame = Instance.new("Frame")
  114.     frame.Name = name
  115.     frame.Size = UDim2.new(0, 300, 0, 50)
  116.     frame.Position = position
  117.     frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  118.     frame.BorderSizePixel = 0
  119.     frame.Parent = mainFrame
  120.  
  121.     local label = Instance.new("TextLabel")
  122.     label.Size = UDim2.new(0, 100, 1, 0)
  123.     label.Position = UDim2.new(0, 0, 0, 0)
  124.     label.BackgroundTransparency = 1
  125.     label.Text = name
  126.     label.TextColor3 = Color3.fromRGB(255, 255, 255)
  127.     label.Parent = frame
  128.  
  129.     local slider = Instance.new("TextBox")
  130.     slider.Name = "Slider"
  131.     slider.Size = UDim2.new(0, 100, 1, 0)
  132.     slider.Position = UDim2.new(0, 110, 0, 0)
  133.     slider.Text = "0"
  134.     slider.TextColor3 = Color3.fromRGB(255, 255, 255)
  135.     slider.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  136.     slider.BorderSizePixel = 0
  137.     slider.Parent = frame
  138.  
  139.     local input = Instance.new("TextBox")
  140.     input.Name = "Input"
  141.     input.Size = UDim2.new(0, 50, 1, 0)
  142.     input.Position = UDim2.new(1, -50, 0, 0)
  143.     input.Text = defaultValues[name]
  144.     input.TextColor3 = Color3.fromRGB(255, 255, 255)
  145.     input.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  146.     input.BorderSizePixel = 0
  147.     input.Parent = frame
  148.  
  149.     return frame
  150. end
  151.  
  152. local SpeedChangerFrame = createSettingFrame("SpeedChanger", UDim2.new(0, 25, 0, 50))
  153. local JumboostChangerFrame = createSettingFrame("JumboostChanger", UDim2.new(0, 25, 0, 110))
  154. local GravityChangerFrame = createSettingFrame("GravityChanger", UDim2.new(0, 25, 0, 170))
  155. local PlayerFovFrame = createSettingFrame("PlayerFov", UDim2.new(0, 25, 0, 230))
  156. local HipHeightFrame = createSettingFrame("HipHeight", UDim2.new(0, 25, 0, 290))
  157. local FPSFrame = createSettingFrame("FPS", UDim2.new(0, 25, 0, 350))
  158. local ZOOMFrame = createSettingFrame("ZOOM", UDim2.new(0, 25, 0, 410))
  159.  
  160. local function createHPFrame(name, position)
  161.     local frame = Instance.new("Frame")
  162.     frame.Name = name
  163.     frame.Size = UDim2.new(0, 300, 0, 100)
  164.     frame.Position = position
  165.     frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  166.     frame.BorderSizePixel = 0
  167.     frame.Parent = mainFrame
  168.  
  169.     local label = Instance.new("TextLabel")
  170.     label.Size = UDim2.new(0, 100, 1, 0)
  171.     label.Position = UDim2.new(0, 0, 0, 0)
  172.     label.BackgroundTransparency = 1
  173.     label.Text = name
  174.     label.TextColor3 = Color3.fromRGB(255, 255, 255)
  175.     label.Parent = frame
  176.  
  177.     local minSlider = Instance.new("TextBox")
  178.     minSlider.Name = "MinSlider"
  179.     minSlider.Size = UDim2.new(0, 100, 0.5, 0)
  180.     minSlider.Position = UDim2.new(0, 110, 0, 0)
  181.     minSlider.Text = "0"
  182.     minSlider.TextColor3 = Color3.fromRGB(255, 255, 255)
  183.     minSlider.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  184.     minSlider.BorderSizePixel = 0
  185.     minSlider.Parent = frame
  186.  
  187.     local maxSlider = Instance.new("TextBox")
  188.     maxSlider.Name = "MaxSlider"
  189.     maxSlider.Size = UDim2.new(0, 100, 0.5, 0)
  190.     maxSlider.Position = UDim2.new(0, 110, 0.5, 0)
  191.     maxSlider.Text = "100"
  192.     maxSlider.TextColor3 = Color3.fromRGB(255, 255, 255)
  193.     maxSlider.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  194.     maxSlider.BorderSizePixel = 0
  195.     maxSlider.Parent = frame
  196.  
  197.     local input = Instance.new("TextBox")
  198.     input.Name = "Input"
  199.     input.Size = UDim2.new(0, 50, 1, 0)
  200.     input.Position = UDim2.new(1, -50, 0, 0)
  201.     input.Text = defaultValues[name .. "Max"]
  202.     input.TextColor3 = Color3.fromRGB(255, 255, 255)
  203.     input.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  204.     input.BorderSizePixel = 0
  205.     input.Parent = frame
  206.  
  207.     return frame
  208. end
  209.  
  210. local HPFrame = createHPFrame("HP", UDim2.new(0, 25, 0, 470))
  211.  
  212. local function slideIn(frame)
  213.     frame.Position = frame.Position + UDim2.new(1, 0, 0, 0)
  214.     frame:TweenPosition(frame.Position - UDim2.new(1, 0, 0, 0), "Out", "Quad", 0.5, true)
  215. end
  216.  
  217. local function slideOut(frame)
  218.     frame:TweenPosition(frame.Position + UDim2.new(1, 0, 0, 0), "Out", "Quad", 0.5, true, function()
  219.         frame.Position = frame.Position - UDim2.new(1, 0, 0, 0)
  220.     end)
  221. end
  222.  
  223. slideIn(SpeedChangerFrame)
  224. slideIn(JumboostChangerFrame)
  225. slideIn(GravityChangerFrame)
  226. slideIn(PlayerFovFrame)
  227. slideIn(HipHeightFrame)
  228. slideIn(FPSFrame)
  229. slideIn(ZOOMFrame)
  230. slideIn(HPFrame)
  231.  
  232. local function updatePlayerAttributes(frame)
  233.     local slider = frame:FindFirstChild("Slider")
  234.     local input = frame:FindFirstChild("Input")
  235.  
  236.     if slider and input then
  237.         local value = tonumber(slider.Text)
  238.         if value then
  239.             input.Text = "Normal" .. frame.Name .. ": " .. value
  240.             if frame.Name == "SpeedChanger" then
  241.                 character.Humanoid.WalkSpeed = value
  242.             elseif frame.Name == "JumboostChanger" then
  243.                 character.Humanoid.JumpPower = value
  244.             elseif frame.Name == "GravityChanger" then
  245.                 game.Workspace.Gravity = value
  246.             elseif frame.Name == "PlayerFov" then
  247.                 camera.FieldOfView = value
  248.             elseif frame.Name == "HipHeight" then
  249.                 character.Humanoid.HipHeight = value
  250.             elseif frame.Name == "FPS" then
  251.                 game:GetService("RunService"):SetFPS(value)
  252.             elseif frame.Name == "ZOOM" then
  253.                 camera.FieldOfView = value
  254.             end
  255.         end
  256.     end
  257. end
  258.  
  259. local function updateHPAttributes(frame)
  260.     local minSlider = frame:FindFirstChild("MinSlider")
  261.     local maxSlider = frame:FindFirstChild("MaxSlider")
  262.     local input = frame:FindFirstChild("Input")
  263.  
  264.     if minSlider and maxSlider and input then
  265.         local minValue = tonumber(minSlider.Text)
  266.         local maxValue = tonumber(maxSlider.Text)
  267.  
  268.         if minValue and maxValue then
  269.             if minValue == 0 then
  270.                 character.Humanoid.Health = 0
  271.                 wait(1)
  272.                 character:BreakJoints()
  273.                 wait(1)
  274.                 character.Humanoid.Health = 100
  275.                 minSlider.Text = "100"
  276.                 input.Text = "HP: 100"
  277.             else
  278.                 if maxValue >= 2000 then
  279.                     input.Text = "God"
  280.                     character.Humanoid.MaxHealth = math.huge
  281.                     character.Humanoid.Health = math.huge
  282.                 else
  283.                     input.Text = "HP: " .. maxValue
  284.                     character.Humanoid.MaxHealth = maxValue
  285.                     character.Humanoid.Health = maxValue
  286.                 end
  287.             end
  288.         end
  289.     end
  290. end
  291.  
  292. local function setupFrame(frame)
  293.     local slider = frame:FindFirstChild("Slider")
  294.     local input = frame:FindFirstChild("Input")
  295.  
  296.     if slider and input then
  297.         slider.FocusLost:Connect(function()
  298.             updatePlayerAttributes(frame)
  299.         end)
  300.  
  301.         input.FocusLost:Connect(function()
  302.             local value = tonumber(input.Text:match("%d+"))
  303.             if value then
  304.                 slider.Text = value
  305.                 updatePlayerAttributes(frame)
  306.             end
  307.         end)
  308.     end
  309. end
  310.  
  311. local function setupHPFrame(frame)
  312.     local minSlider = frame:FindFirstChild("MinSlider")
  313.     local maxSlider = frame:FindFirstChild("MaxSlider")
  314.     local input = frame:FindFirstChild("Input")
  315.  
  316.     if minSlider and maxSlider and input then
  317.         minSlider.FocusLost:Connect(function()
  318.             updateHPAttributes(frame)
  319.         end)
  320.  
  321.         maxSlider.FocusLost:Connect(function()
  322.             updateHPAttributes(frame)
  323.         end)
  324.     end
  325. end
  326.  
  327. setupFrame(SpeedChangerFrame)
  328. setupFrame(JumboostChangerFrame)
  329. setupFrame(GravityChangerFrame)
  330. setupFrame(PlayerFovFrame)
  331. setupFrame(HipHeightFrame)
  332. setupFrame(FPSFrame)
  333. setupFrame(ZOOMFrame)
  334. setupHPFrame(HPFrame)
  335.  
Tags: Roblox lua Gui
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement