I have a model that is like a security vest. What I want to accomplish is having the Torso clone to the player's Torso. The game uses R15 Player Models. Here's my code.
local group = 5701845
function onTouched(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr:GetRankInGroup(group) >= 1 then
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Torso") == nil then
hit.Parent.Humanoid.MaxHealth = 150
hit.Parent.Humanoid.Health = 150
local vest = script.Parent.Parent.Torso:Clone()
for i, desc in ipairs(vest:GetDescendants()) do
if desc:IsA("BasePart") or desc:IsA("UnionOperation") then
desc.Anchored = false
desc.CanCollide = false
local weld = Instance.new("WeldConstraint")
weld.Part0 = plr.Character.HumanoidRootPart
weld.Part1 = desc
weld.Parent = plr.Character.HumanoidRootPart
vest.PrimaryPart = plr.Character.HumanoidRootPart
vest.Parent = plr.Character.HumanoidRootPart
end
end
end
end
end
script.Parent.Touched:connect(onTouched)
This only locks the player in their position, I presume from the Weld Constraint. What is the correct way to do this?
