Advertisement
HowToRoblox

ArmorHandler

Oct 22nd, 2021
1,939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. local armorModel = script.Parent:WaitForChild("Armor")
  2.  
  3. local pad = script.Parent:WaitForChild("MorphPad")
  4.  
  5.  
  6. pad.Touched:Connect(function(hit)
  7.    
  8.     local p = game.Players:GetPlayerFromCharacter(hit.Parent)
  9.    
  10.     if p then
  11.        
  12.         if p.Character:FindFirstChild("Armor") then
  13.            
  14.             p.Character.Armor:Destroy()
  15.         end
  16.        
  17.        
  18.         local newHealth = armorModel.NewHealth.Value
  19.        
  20.         p.Character.Humanoid.MaxHealth = newHealth
  21.         p.Character.Humanoid.Health = newHealth
  22.        
  23.        
  24.         local newArmor = armorModel:Clone()
  25.        
  26.        
  27.         for i, child in pairs(newArmor:GetChildren()) do
  28.            
  29.            
  30.             if child:IsA("Model") then
  31.            
  32.                 for x, descendant in pairs(child:GetDescendants()) do
  33.                    
  34.                     if descendant:IsA("BasePart") then descendant.Anchored = false end
  35.                 end
  36.                
  37.                
  38.                 local bodyPart = p.Character:FindFirstChild(child.Name)
  39.                
  40.                 child:SetPrimaryPartCFrame(bodyPart.CFrame)
  41.                
  42.                
  43.                 local weld = Instance.new("WeldConstraint", child.PrimaryPart)
  44.                
  45.                 weld.Part0 = bodyPart
  46.                 weld.Part1 = child.PrimaryPart
  47.             end
  48.         end
  49.        
  50.         newArmor.Parent = p.Character
  51.     end
  52. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement