So, I have a tool and a vest in a folder called Vests in ServerStorage. I want it so that if you click with the tool equipped, it'll put the vest on the player. The vest is called SBAV, it's a meshpart. Here's the script:
local Vest = game.ServerStorage.Vests:WaitForChild("SBAV")
function onActivation()
local g = Vest:Clone()
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = onActivation.Parent.SBAV
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
onActivation.Activated:Connect(onActivation)

1 comment
Global Guidlines - 3. Answers must show reasonable attempt to solve the question. Explain what went wrong.^ Provide code as an example. Include the explanation of the code.^