Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local localPlayer = Players.LocalPlayer
- local boxes = {}
- -- Usar valores globales definidos fuera o valores predeterminados
- local Ancho = _G.Ancho or 6
- local Altura = _G.Altura or 10
- local fixedBoxSize = Vector3.new(Ancho, Altura, 1)
- local function playerHasItems(player)
- local character = player.Character
- if not character then return false end
- if character:FindFirstChildOfClass("Tool") then
- return true
- end
- local backpack = player:FindFirstChildOfClass("Backpack")
- if backpack and #backpack:GetChildren() > 0 then
- return true
- end
- return false
- end
- local function updateBox(player)
- if not _G.enablecuadrohit then return end -- Verificar si la funcionalidad está habilitada
- if player == localPlayer then return end
- local character = player.Character
- if not character then return end
- if playerHasItems(player) then
- if not boxes[player] then
- local box = Instance.new("Part")
- box.Anchored = true
- box.CanCollide = false
- box.Transparency = 0.5
- box.Color = Color3.new(1, 0, 0)
- box.Size = fixedBoxSize
- box.Parent = workspace
- boxes[player] = box
- end
- local box = boxes[player]
- box.CFrame = character:WaitForChild("HumanoidRootPart").CFrame
- else
- if boxes[player] then
- boxes[player]:Destroy()
- boxes[player] = nil
- end
- end
- end
- local function onPlayerAdded(player)
- if player ~= localPlayer then
- player.CharacterAdded:Connect(function(character)
- character:WaitForChild("HumanoidRootPart")
- updateBox(player)
- end)
- player.Backpack.ChildAdded:Connect(function()
- updateBox(player)
- end)
- player.Backpack.ChildRemoved:Connect(function()
- updateBox(player)
- end)
- player.CharacterAdded:Connect(function(character)
- updateBox(player)
- character.ChildAdded:Connect(function(child)
- if child:IsA("Tool") then
- updateBox(player)
- end
- end)
- character.ChildRemoved:Connect(function(child)
- if child:IsA("Tool") then
- updateBox(player)
- end
- end)
- end)
- RunService.Heartbeat:Connect(function()
- updateBox(player)
- end)
- end
- end
- for _, player in ipairs(Players:GetPlayers()) do
- onPlayerAdded(player)
- end
- Players.PlayerAdded:Connect(onPlayerAdded)
- Players.PlayerRemoving:Connect(function(player)
- if boxes[player] then
- boxes[player]:Destroy()
- boxes[player] = nil
- end
- end)
- RunService.Heartbeat:Connect(function()
- for player, box in pairs(boxes) do
- if player.Character then
- local humanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
- if humanoidRootPart then
- box.CFrame = humanoidRootPart.CFrame
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement