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

How does tool welding work?

Asked by 9 years ago

I am starting to get the basics but I still don't understand how people create functions for weapons such as crouch and crawl. I realize some people copy these functions but I would like to do it myself so it is more original and I can understand it. At the moment I am trying to simply weld the arms when the tool is selected so that both arms are gripping the tool, not just one. I have tried looking at complex scripts but its a bit confusing to me since I haven't really learned things like sine and cosine yet, I've only learned Algebra 1 stuff so far. If someone could help me that would be great! If this is off-topic please let me know where I should be requesting for help!

1 answer

Log in to vote
0
Answered by
KenzaXI 166
9 years ago

Ok first, You insert a Tool into the workspace (Name the Tool, what it is, Example "Sword") Insert a Part into the tool and name it "Handle" Then insert a Weld into the Tool If you've coded it put the script inside the Handle. Drag the tool into the starter pack and insert this script into the Tool:

function Weld(x,y)
    local W = Instance.new("Weld")
    W.Part0 = x
    W.Part1 = y
    local CJ = CFrame.new(x.Position)
    local C0 = x.CFrame:inverse()*CJ
    local C1 = y.CFrame:inverse()*CJ
    W.C0 = C0
    W.C1 = C1
    W.Parent = x
end

function Get(A)
    if A.className == "Part" then
        Weld(script.Parent.Handle, A)
        A.Anchored = false
    else
        local C = A:GetChildren()
        for i=1, #C do
        Get(C[i])
        end
    end
end

function Finale()
    Get(script.Parent)
end

script.Parent.Equipped:connect(Finale)
script.Parent.Unequipped:connect(Finale)
Finale()
0
this does not help whatsoever, and you need to provide code!!! dragonkeeper467 453 — 9y
Ad

Answer this question