So i made a weapon which has some animation in it by using CFraming but as soon as used the tool and played the parts animation the player also moves. So is there a way to move parts w/o moving the player with it?
So you want to move parts of a tool around, but without having any effect on the character model?
To do this, you have to understand a few things;
1) - The reason why tools hold together when you equip them is because they're Welded together. This can either occur before or during the action of equipping the tool, with a weld script.
Weld scripts weld entire models together, done by iterating
through the entire model and welding parts together.
2) The reason why when using a weld script on a model, all the parts don't just clump together is because of the C0
and C1
properties of the weld object. The C0 and C1 properties are Weld offsets - meaning that you can move and rotate the two welded parts away from eachother while still being welded.
So, now with this prior knowledge.. can you see why CFraming one part of a model that's entirely welded together(also welded partially to your Character model through the tool weld) would in turn manipulate the character?
If you have 3 parts stuck together, and move one of them then the third is going to move relative to the first. Because they're stuck together.
So to fix your problem, you have to use the C0
and C1
properties of the Welds
in which your parts are stuck together by. By doing this, you will offset the welds, rather than moving the entire position of the model.
An example of doing this could be;
local model = workspace.Model local part = model.Part for i = 1,360 do part.Weld.C0 = part.Weld.C0 * CFrame.new(0,1,0) * CFrame.Angles(math.rad(3),0,0) wait() end
NOTE: The syntax for CFraming welds is;
C0 = CFrame.new(offset) * CFrame.Angles(math.rad(rotation))