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

How do I rotate a part from a weld?

Asked by 5 years ago
Edited 5 years ago

I have been following the "First Person Shooter" guide in the ScriptingHelpers blog, but when I weld the weapon with the character's right hand in the server script, I get some undesirable results. This can be seen here, https://i.gyazo.com/398fb3ac2663f617954ebcd4a43aaf4f.png

Code:

local pistol = body:Clone();
pistol.CFrame = player.Character.RightHand.CFrame
local joint = Instance.new("Weld")
joint.Part0 = pistol;
joint.Part1 = player.Character.RightHand;
joint.C0 = player.Character.RightHand.CFrame;
joint.C1 = pistol.CFrame;
joint.Parent = pistol;
pistol.Parent = player.Character;

I have tried rotating the pistol to it's correct position, but for some reason, the pistol is not rotated but rather moved rather far away from the original character. This can be seen here, https://i.gyazo.com/dc00e3eccbcb204ba97379761357a804.png

Code:

local pistol = body:Clone();
pistol.CFrame = player.Character.RightHand.CFrame
local joint = Instance.new("Weld")
joint.Part0 = pistol;
joint.Part1 = player.Character.RightHand;
joint.C0 = player.Character.RightHand.CFrame*CFrame.Angles(math.rad(-90), 0, math.rad(90));
joint.C1 = pistol.CFrame;
joint.Parent = pistol;
pistol.Parent = player.Character;

I do not understand what is causing this, so if you can help me, that would be great!

1
C0 and C1 are just offsets so you are saying to include the hand CFrame with the offset. User#5423 17 — 5y

Answer this question