Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Esp")
- -- Function to create a hitbox for a character
- local function createHitbox(character)
- for _, part in pairs(character:GetChildren()) do
- if part:IsA("BasePart") then
- local hitbox = part:FindFirstChild("Hitbox")
- if not hitbox then
- hitbox = Instance.new("SelectionBox")
- hitbox.Name = "Hitbox"
- hitbox.Adornee = part
- hitbox.Parent = part
- hitbox.Color3 = Color3.new(1, 0, 0) -- Set the hitbox color (red in this example)
- hitbox.LineThickness = 0.05 -- Adjust the hitbox thickness as needed
- end
- end
- end
- end
- -- Function to remove hitboxes from a character
- local function removeHitbox(character)
- for _, part in pairs(character:GetChildren()) do
- if part:IsA("BasePart") then
- local hitbox = part:FindFirstChild("Hitbox")
- if hitbox then
- hitbox:Destroy()
- end
- end
- end
- end
- -- Function to draw hitboxes for a player
- local function drawPlayerHitbox(player)
- local character = player.Character
- if character then
- createHitbox(character)
- end
- end
- -- Function to handle player character changes
- local function onCharacterAdded(character)
- createHitbox(character)
- end
- local function onCharacterRemoved(character)
- removeHitbox(character)
- end
- -- Function to continuously check for new players and draw their hitboxes
- local function checkForNewPlayers()
- while true do
- for _, player in pairs(game:GetService("Players"):GetPlayers()) do
- drawPlayerHitbox(player)
- end
- wait(1) -- Adjust the delay as needed (1 second in this example)
- end
- end
- -- Start the loop in a separate thread to avoid script termination
- spawn(checkForNewPlayers)
- -- Connect an event to draw hitboxes for newly added players
- game:GetService("Players").PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(onCharacterAdded)
- player.CharacterRemoving:Connect(onCharacterRemoved)
- drawPlayerHitbox(player)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement