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

How to move parts in tool w/o moving your player?

Asked by 9 years ago

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?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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 Weldsin 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))

0
does it work for unions? Arnel050039 20 — 9y
0
There's no reason it shouldn't(: Goulstem 8144 — 9y
0
I tried doing a walkthrough of it (the example you made) it says weld is not a valid member of Part Arnel050039 20 — 9y
0
It's an example silly, you have to make your own code that matches your purpose. You got that error because there was no weld in whatever part you were indexing. Goulstem 8144 — 9y
View all comments (4 more)
0
where other links or website can i learn this stuff? Arnel050039 20 — 9y
0
Ehhhh... wiki.roblox.com The thing is that there's no definite answer for your problem, you need to figure it out yourself with prior Lua knowledge, otherwise someone's just doing it for you. Goulstem 8144 — 9y
0
Ok thank you for your answers you really helped alot :D Arnel050039 20 — 9y
0
Anytime(: Goulstem 8144 — 9y
Ad

Answer this question