I am currently making the reload animation for my gun scripts, however I have encountered a problem.
Whenever I try to set the positions of the player's arms, my character flips over. The arm stays the same position in respect to the torso, but the character is completely flipped over.
Here's the code:
local weld55 = Instance.new("Weld") local weld33 = Instane.new("Weld") function Equip() PrevIcon = mouse.Icon mouse.Icon = "http://www.roblox.com/asset/?id=122932672" weld55.C1 = CFrame.new(0,0,0) * CFrame.Angles(math.rad(0),math.rad(-30),math.rad(-90)) weld33.C1 = CFrame.new(0,0,0) end
I have no Idea what is wrong, any suggestions?
Prerequisites Being able to use a basic CFrame (CFrame.new(#, #, #)). Knowing how to index and change the properties of an object, using a script. Basic structure of a weld.
The weld object is placed inside of a part, and a property is set to determine which other part should be welded to the original part. Then two CFrames, the C0 and the C1, tell the weld how the parts should be placed.
Part0 This property of a weld is an Object, it must always be set to the part the weld is in for the weld to work Part1 This property of a weld is an object and tells is which part it should be attaching its parent to C0 determines how the [offset point] should be attached to the Part0 C1 determines how the Part1 should be attached to the [offset point]
Advanced Part1.CFrame * C1 == Part0.CFrame * C0
Setting the values Figuring out what to set the C0 and C1 to is a bit finicky, but one you get good at it, it can go quite quickly. For Welds, you dont have to worry about the C1, it's automaticaly set to a "unit" or unrotated CFrame, you only have to deal with C1 when working with motors, so ignore it for now. The C0 will tell the weld how it should attatch itself to the other part, eg.
[weld].C0 = CFrame.new(0, 2, 0)
This tells the weld that it should hold the part1 in a position 2 studs above the part0, simple eh?