Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local armorpieces = game:GetService("ReplicatedStorage"):WaitForChild("ArmorPieces")
- function removeFunc(plr:Player, armortype:string) --Putting equipped armor into a player's inventory
- local char = plr.Character
- if char and char:FindFirstChild("Humanoid") and char.Humanoid.Health > 0 then
- local inv = plr:WaitForChild("ArmorInventory")
- local equipped = plr:WaitForChild("ArmorEquipped")
- local currentArmor = equipped[armortype]
- if currentArmor.Value ~= nil then
- local healthGain = currentArmor.Value.Stats.Health.Value
- local speedGain = currentArmor.Value.Stats.Speed.Value
- char.Humanoid.MaxHealth -= healthGain
- char.Humanoid.WalkSpeed -= speedGain
- if char.Humanoid.Health > char.Humanoid.MaxHealth then
- char.Humanoid.Health = char.Humanoid.MaxHealth
- end
- for _, armorpiece in pairs(armorpieces:GetDescendants()) do
- if armorpiece.Name == currentArmor.Value.Name and armorpiece.Parent.Parent == armorpieces then
- armorpiece:Clone().Parent = inv
- break
- end
- end
- currentArmor.Value:Destroy()
- currentArmor.Value = nil
- end
- end
- end
- return removeFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement