Advertisement
Guest User

Hitbox expander gui (made by me)

a guest
Aug 23rd, 2024
11,669
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.98 KB | None | 1 0
  1. -- Function to create GUI
  2. local function createHitboxGui()
  3.     -- Check if GUI already exists and remove it to avoid duplicates
  4.     if game.Players.LocalPlayer.PlayerGui:FindFirstChild("HitboxGui") then
  5.         game.Players.LocalPlayer.PlayerGui:FindFirstChild("HitboxGui"):Destroy()
  6.     end
  7.  
  8.     -- Create GUI
  9.     local ScreenGui = Instance.new("ScreenGui")
  10.     ScreenGui.Name = "HitboxGui"
  11.     ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  12.  
  13.     local Frame = Instance.new("Frame")
  14.     Frame.Parent = ScreenGui
  15.     Frame.Size = UDim2.new(0, 200, 0, 100)
  16.     Frame.Position = UDim2.new(0, 10, 1, -110)
  17.     Frame.AnchorPoint = Vector2.new(0, 1)
  18.     Frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)  -- Dark gray background
  19.     Frame.BorderSizePixel = 0
  20.     Frame.BackgroundTransparency = 0.2
  21.     Frame.Active = true
  22.  
  23.     local TextBox = Instance.new("TextBox")
  24.     TextBox.Parent = Frame
  25.     TextBox.Size = UDim2.new(1, -10, 0.4, -5)
  26.     TextBox.Position = UDim2.new(0, 5, 0, 5)
  27.     TextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
  28.     TextBox.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
  29.     TextBox.Text = "Enter hitbox size"
  30.     TextBox.ClearTextOnFocus = true
  31.  
  32.     local TeamButton = Instance.new("TextButton")
  33.     TeamButton.Parent = Frame
  34.     TeamButton.Size = UDim2.new(1, -10, 0.4, -5)
  35.     TeamButton.Position = UDim2.new(0, 5, 0.5, 5)
  36.     TeamButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)  -- Darker gray background
  37.     TeamButton.TextColor3 = Color3.fromRGB(255, 255, 255)  -- White text
  38.     TeamButton.Text = "Toggle Team Check"
  39.  
  40.     local TextLabel = Instance.new("TextLabel")
  41.     TextLabel.Parent = Frame
  42.     TextLabel.Size = UDim2.new(1, -10, 0.2, -5)
  43.     TextLabel.Position = UDim2.new(0, 5, 0.9, 5)
  44.     TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
  45.     TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
  46.     TextLabel.Text = "Hitbox Size: 1"
  47.     TextLabel.TextScaled = true
  48.  
  49.     -- Handle Input
  50.     local hitboxSize = 1
  51.     local teamCheck = false
  52.  
  53.     TextBox.FocusLost:Connect(function(enterPressed)
  54.         if enterPressed then
  55.             local inputText = TextBox.Text
  56.             local inputNumber = tonumber(inputText)
  57.             if inputNumber then
  58.                 hitboxSize = inputNumber
  59.                 TextLabel.Text = "Hitbox Size: " .. hitboxSize
  60.  
  61.                 -- Function to apply hitbox changes
  62.                 local function applyHitbox(player)
  63.                     if player ~= game.Players.LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  64.                         if not teamCheck or (teamCheck and player.Team ~= game.Players.LocalPlayer.Team) then
  65.                             local hitbox = player.Character.HumanoidRootPart
  66.                             hitbox.Size = Vector3.new(hitboxSize, hitboxSize, hitboxSize)
  67.                             hitbox.Transparency = 0.75
  68.                             hitbox.CanCollide = false
  69.  
  70.                             -- Add a visualizer
  71.                             if not hitbox:FindFirstChild("HitboxVisualizer") then
  72.                                 local hitboxVisualizer = Instance.new("SelectionBox")
  73.                                 hitboxVisualizer.Name = "HitboxVisualizer"
  74.                                 hitboxVisualizer.Adornee = hitbox
  75.                                 hitboxVisualizer.Parent = hitbox
  76.                             end
  77.                         end
  78.                     end
  79.                 end
  80.  
  81.                 -- Apply hitbox changes to all current players
  82.                 for _, player in pairs(game.Players:GetPlayers()) do
  83.                     applyHitbox(player)
  84.                     -- Reapply hitbox changes on respawn
  85.                     player.CharacterAdded:Connect(function()
  86.                         wait(1) -- Optional: Wait for the character to load
  87.                         applyHitbox(player)
  88.                     end)
  89.                 end
  90.  
  91.                 -- Reapply hitbox changes for new players joining the game
  92.                 game.Players.PlayerAdded:Connect(function(player)
  93.                     player.CharacterAdded:Connect(function()
  94.                         wait(1) -- Optional: Wait for the character to load
  95.                         applyHitbox(player)
  96.                     end)
  97.                 end)
  98.             else
  99.                 TextLabel.Text = "Invalid number"
  100.             end
  101.             TextBox.Text = ""
  102.         end
  103.     end)
  104.  
  105.     -- Toggle team check
  106.     TeamButton.MouseButton1Click:Connect(function()
  107.         teamCheck = not teamCheck
  108.         TeamButton.Text = teamCheck and "Team Check: ON" or "Team Check: OFF"
  109.     end)
  110. end
  111.  
  112. -- Initialize GUI on script load
  113. createHitboxGui()
  114.  
  115. -- Recreate GUI when the player's character is added (handles respawns)
  116. game.Players.LocalPlayer.CharacterAdded:Connect(function()
  117.     wait(1) -- Optional: Wait for the character to load
  118.     createHitboxGui()
  119. end)
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement