Hellmet-style gun system

I have made a Hellmet-style gun system, but an uncalled-for roadblock has emerged. I have prepared a clip:

Medal clip:

Hellmet Roblox (Inspiration for the gun system): HELLMET [OPEN ALPHA] - Roblox

What is the issue? Well, when I walk backward, the hands seem to glitch out (Teleporting everywhere), and I have no clue what is going on. I have pondered the question for days, but I have not found a solution.

Here are the functions that I use to align the arms.

local function setup_arms()
	
	local torso = character:FindFirstChild("Torso")
	local right_shoulder = torso:FindFirstChild("Right Shoulder")
	local left_shoulder = torso:FindFirstChild("Left Shoulder")

	-- Store original C0 values for proper offsets
	character:SetAttribute("RightShoulderC0", right_shoulder.C0)
	character:SetAttribute("LeftShoulderC0", left_shoulder.C0)
end

local function point_arms()
	local torso = character:FindFirstChild("Torso")
	local right_shoulder = torso:FindFirstChild("Right Shoulder")
	local left_shoulder = torso:FindFirstChild("Left Shoulder")

	local rightC0Original = character:GetAttribute("RightShoulderC0")
	local leftC0Original = character:GetAttribute("LeftShoulderC0")

	-- Target positions in world space
	local rightTargetWorld = current_gun.right_hand.Position
	local leftTargetWorld = current_gun.left_hand.Position

	-- Midway positions 
	local rightMidway = rightC0Original.Position:Lerp(torso.CFrame:PointToObjectSpace(rightTargetWorld), 0.5)
	local leftMidway = leftC0Original.Position:Lerp(torso.CFrame:PointToObjectSpace(leftTargetWorld), 0.5)

	-- Compute rotation to point at the target
	local rightRotation = CFrame.lookAt(torso.CFrame:PointToWorldSpace(rightMidway), rightTargetWorld)
	local leftRotation = CFrame.lookAt(torso.CFrame:PointToWorldSpace(leftMidway), leftTargetWorld)

	-- Convert to torso's object space
	rightRotation = torso.CFrame:ToObjectSpace(rightRotation)
	leftRotation = torso.CFrame:ToObjectSpace(leftRotation)

	-- Apply 90-degree correction around the X-axis
	local rotationCorrection = CFrame.Angles(math.rad(90), 0, 0)

	-- Apply new position and rotation
	right_shoulder.C0 = CFrame.new(rightMidway) * rightRotation.Rotation * rotationCorrection
	left_shoulder.C0 = CFrame.new(leftMidway) * leftRotation.Rotation * rotationCorrection
end

I don’t know if it’s just me but your Medal clip is not loading.

1 Like

The issue should be fixed now.

From what I’m seeing in the video is a collision fighting issue with the arms and gun while moving. (if that’s not the case) Could be your update doing a late update after the gun moves.

Lets say that it is a collision fighting issue, what steps can I take to fix the sitsuation? But I highly doubt that it would be a collision fighting issue. Ill look into the late update thing. And also the glitching only happens when I walk backwards, everything is fine when I move side to side or forwards.

I fixed it. The problem was that the characters “AutoRotate” property was set to True.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.