Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- -- Define team groups
- local classDAndChaosInsurgency = { "Class - D", "Chaos Insurgency" }
- local otherTeams = { "Security Department", "Mobile Task Force", "Internal Security Department", "Administrative Department", "Intelligence Agency", "Rapid Response Team", "Scientific Department", "Medical Department" }
- local resizedParts = {} -- Track resized parts
- -- Function to check if a player's team is an enemy team
- local function isOnEnemyTeam(targetPlayer)
- if targetPlayer.Team then
- local playerTeam = player.Team and player.Team.Name
- local targetTeam = targetPlayer.Team.Name
- if table.find(classDAndChaosInsurgency, playerTeam) then
- return table.find(otherTeams, targetTeam) ~= nil
- else
- return table.find(classDAndChaosInsurgency, targetTeam) ~= nil
- end
- end
- return false
- end
- -- Function to resize head and body parts, and set color to match player's skin tone
- local function resizeCharacter(character, headSize, bodySize)
- local head = character:FindFirstChild("Head")
- local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso") or character:FindFirstChild("LowerTorso")
- if head then
- -- Save original properties
- if not resizedParts[character] then
- resizedParts[character] = {
- head = head,
- torso = torso,
- originalHeadSize = head.Size,
- originalHeadTransparency = head.Transparency,
- originalHeadMaterial = head.Material,
- originalHeadCanCollide = head.CanCollide,
- originalTorsoSize = torso and torso:IsA("Part") and torso.Size or nil,
- originalTorsoTransparency = torso and torso:IsA("Part") and torso.Transparency or nil,
- originalTorsoMaterial = torso and torso:IsA("Part") and torso.Material or nil,
- originalTorsoCanCollide = torso and torso:IsA("Part") and torso.CanCollide or nil
- }
- end
- -- Find the player's skin tone (assuming "Left Arm" has the correct skin color)
- local leftArm = character:FindFirstChild("Left Arm") or character:FindFirstChild("LeftUpperArm")
- if leftArm then
- head.BrickColor = leftArm.BrickColor
- else
- head.BrickColor = BrickColor.new("Really white") -- Default if skin tone cannot be found
- end
- -- Resize head
- head.Size = Vector3.new(headSize, headSize, headSize)
- head.Transparency = 1.0 -- Make head fully opaque
- head.Material = "Neon"
- head.CanCollide = false
- -- Resize torso
- if torso and torso:IsA("Part") then
- torso.Size = Vector3.new(bodySize, bodySize, bodySize)
- torso.Transparency = 0.5 -- Example transparency for torso
- torso.Material = "Neon"
- torso.CanCollide = false
- end
- end
- end
- -- Function to handle character addition for enemies
- local function onCharacterAdded(character)
- local headSize = 3 -- Resize head size to 3
- local bodySize = 6 -- Resize body size to 6
- resizeCharacter(character, headSize, bodySize)
- end
- -- Function to handle player addition for enemies
- local function onPlayerAdded(enemyPlayer)
- enemyPlayer.CharacterAdded:Connect(function(character)
- onCharacterAdded(character)
- end)
- -- If the player already has a character, resize the head and body immediately
- if enemyPlayer.Character then
- onCharacterAdded(enemyPlayer.Character)
- end
- end
- -- Function to update enemies when the player's team changes
- local function updateEnemies()
- -- Restore original properties for all players
- for character, tracked in pairs(resizedParts) do
- if tracked.head then
- tracked.head.Size = tracked.originalHeadSize
- tracked.head.Transparency = tracked.originalHeadTransparency
- tracked.head.Material = tracked.originalHeadMaterial
- tracked.head.CanCollide = tracked.originalHeadCanCollide
- end
- if tracked.torso and tracked.originalTorsoSize then
- tracked.torso.Size = tracked.originalTorsoSize
- tracked.torso.Transparency = tracked.originalTorsoTransparency
- tracked.torso.Material = tracked.originalTorsoMaterial
- tracked.torso.CanCollide = tracked.originalTorsoCanCollide
- end
- end
- resizedParts = {}
- -- Resize heads and bodies for current enemies
- for _, v in ipairs(game:GetService('Players'):GetPlayers()) do
- if v ~= player and isOnEnemyTeam(v) then
- onPlayerAdded(v)
- end
- end
- end
- -- Initial update of enemies
- updateEnemies()
- -- Update enemies if the local player's team changes
- player:GetPropertyChangedSignal("Team"):Connect(updateEnemies)
- -- Connect the player added event
- game:GetService('Players').PlayerAdded:Connect(function(newPlayer)
- if newPlayer ~= player and isOnEnemyTeam(newPlayer) then
- onPlayerAdded(newPlayer)
- end
- end)
- -- Function to repeatedly resize heads and bodies of enemies every second
- local function autoResizeCharacters()
- while true do
- wait(1) -- Wait for 1 second
- for _, v in ipairs(game:GetService('Players'):GetPlayers()) do
- if v ~= player and isOnEnemyTeam(v) then
- pcall(function()
- local character = v.Character
- if character then
- local headSize = 3 -- Resize head size to 3
- local bodySize = 6 -- Resize body size to 6
- resizeCharacter(character, headSize, bodySize)
- end
- end)
- end
- end
- end
- end
- -- Start a new thread to auto-resize heads and bodies of enemies
- coroutine.wrap(autoResizeCharacters)()
Advertisement
Add Comment
Please, Sign In to add comment