I have made armor for one of my games. The goal is to make it spawn around the map and if a player touches it, it gets welded to the players torso. I have one issue though. It welds completely wrong.
Code:
local armor = workspace.Armor
local part = script.Parent
local debounce = false
part.Touched:Connect(function(hit)
local torso = hit.Parent:FindFirstChild(“HumanoidRootPart”)
if debounce == false and torso then
debounce = true
local newArmor = armor:Clone()
armor:SetPrimaryPartCFrame(torso.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(90), 35)))
local weld = Instance.new(“Weld”, torso)
weld.Part0 = torso
weld.Part1 = armor.PrimaryPart
hit.Parent.Humanoid.MaxHealth = hit.Parent.Humanoid.MaxHealth + 100
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.MaxHealth
wait(120)
armor = newArmor
armor.Parent = workspace
debounce = false
end
end)
Any feedback/support would be greatly appreciated!