Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make a script to equip a vest with a tool?

Asked by 5 years ago

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
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.^ s_21 74 — 5y

1 answer

Log in to vote
0
Answered by
Robowon1 323 Moderation Voter
5 years ago

This isn't a request forum, you haven't provided any insight into what you've tried and what problems you've encountered.

Ad

Answer this question