Attaching Part to Right and Left GripAttachment Problem

If someone can help me fix this issue I would appreciate it, The problem is when I rotate my character the guns rotate on the players arms, video below

I’ve looked all over the dev hub and haven’t found anything about this…

-- Current Code This is a server script attached to the player in starter character scripts for server streaming

		Gun1Clone.WeldConstraint.Part0 = Gun1Clone
		Gun1Clone.WeldConstraint.Part1 = Character:FindFirstChild("Left Arm")
		
		Gun2Clone.WeldConstraint.Part0 = Gun2Clone
		Gun2Clone.WeldConstraint.Part1 = Character:FindFirstChild("Right Arm")
		
		Gun1Clone.Position = Character:FindFirstChild("Left Arm"):FindFirstChild("LeftGripAttachment").WorldCFrame.Position
		Gun2Clone.Position = Character:FindFirstChild("Right Arm"):FindFirstChild("RightGripAttachment").WorldCFrame.Position
		
		Gun1Clone.Parent = Character:FindFirstChild("Left Arm"):FindFirstChild("LeftGripAttachment")
		Gun2Clone.Parent = Character:FindFirstChild("Right Arm"):FindFirstChild("RightGripAttachment")
1 Like

The issue is because you’re just setting the position of the guns, not the CFrame.
What you need to instead is set it to the CFrame of the attachments.

local function SetupGun(side: string)
	local Arm = Character:FindFirstChild(side .. ' Arm')
	local Grip = Arm:FindFirstChild(side .. 'GripAttachment')
	
	local GunClone = GunPrefab:Clone() -- cloning the gun asset
	GunClone.WeldConstraint.Part0 = GunClone
	GunClone.WeldConstraint.Part1 = Arm
	GunClone.CFrame = Grip.WorldCFrame -- instead of position setting the CFrame (cframe is position + rotation)
end

SetupGun('Left')
SetupGun('Right')

This still doesnt fix the guns being upside down

image_2024-09-05_163240171

Multiply the CFrame by CFrame.Angles and then check which value it should be rotated to.
I think something like this would work:

GunClone.CFrame = Grip.WorldCFrame * CFrame.Angles(0, 0, math.rad(180))
1 Like

Thank you so much this worked, I’m sorry If I seemed dumb that I didn’t know that. I appreciate you a lot :fist_right::fist_left:

1 Like