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")
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')