Some parts in gun going crazy

I’m creating an FPS gun system. In the guns, there is a Component folder that holds small, invisible regular parts that are essential to the system working correctly. Right now, there is Fire and Aim, which are both motored to the Main part just like any other part of the gun, but in testing, they go absolutely crazy and firing the gun makes it go in some random direction from thousands of studs away.

(If that was too long to read, the video is pretty self-explanatory)

What can I do? I’ve tried making a new gun model and making sure it was motored correctly, but it didn’t work.

You could try making all the gun parts massless.

In addition to this, how did you attach the fire part to the gun? You could try using a generic weld instead because I don’t see a need for a motor here, as it shouldn’t need to be animated at all.

1 Like

Tried both, none worked. However, after making the welds, just one time (this didn’t happen any other time) I tested it suddenly corrected itself after a bit of shooting?
Also, the welds make the parts drop a little bit for some reason.

The fact that the Fire part has RootPriority of 0, yet is its own AssemblyRootPart indicates that it’s not welded to anything. Have you checked to make sure the Motor6D/Weld is both setup correctly and showing as both Active and Enabled during PlaySolo? Maybe the motor is disabled, disconnected, or not being activated due to some other condition not being right?

The Fire part isn’t just freefalling either, you can see it’s traveling in a specific directly and accelerating too, which means there is either a force on it from something. Any chance you have the Aerodynamics beta feature turned on and GlobalWind set? Any bodymovers or other constraints involved? Are any scripts updating the CFrame of anything in the assembly, and if so, on what RunService event?

Probably this can’t be solved without a repro place file, there are many things we can’t see from the video that could be the problem.

Everything you described is all good, the only thing that changes the CFrame of anything in the viewmodel is my RenderStepped function:

local function renderStepped(dt)
	if systemEnabled then
		if viewmodel and weapon then
			local cameraBone = viewmodel:FindFirstChild("CameraBone")
			
			local components = weapon:FindFirstChild("Components")
			
			local mouseDelta = userInputService:GetMouseDelta()
			
			if idle then
				local bobble = Vector3.new(getIdleBob(10), getIdleBob(5), getIdleBob(5))
				
				springs.bobble:shove(bobble / 15 * (1 / 20))
			else
				local bobble = Vector3.new(getNormalBob(10), getNormalBob(5), getNormalBob(5))
				
				if aiming then
					springs.bobble:shove(bobble / 30 * (humanoidRootPart.Velocity.Magnitude) / 30)
				else
					springs.bobble:shove(bobble / 15 * (humanoidRootPart.Velocity.Magnitude) / 15)
				end
			end
			
			if aiming then
				springs.sway:shove(Vector3.new(-mouseDelta.X / 2000, mouseDelta.Y / 800, 0))
			else
				springs.sway:shove(Vector3.new(-mouseDelta.X / 1000, mouseDelta.Y / 400, 0))
			end
			
			local updatedSprings = {
				recoil = springs.recoil:update(dt),
				bobble = springs.bobble:update(dt),
				sway = springs.sway:update(dt)
			}
			
			if cameraBone and components then
				cameraBone.CFrame = camera.CFrame
				
				local aim = components:FindFirstChild("Aim")
				if aim then
					aim.CFrame = aim.CFrame:Lerp(cameraBone.CFrame, aimValue.Value)
				end
				
				cameraBone.CFrame = cameraBone.CFrame:ToWorldSpace(CFrame.new(updatedSprings.bobble.Y, updatedSprings.bobble.X, 0))
				cameraBone.CFrame *= CFrame.Angles(math.rad(updatedSprings.recoil.X) * 2, 0, 0)
				cameraBone.CFrame *= CFrame.Angles(-updatedSprings.sway.Y, updatedSprings.sway.X, 0)
				
				aim.CFrame *= strafeValue.Value
				
				camera.CFrame *= CFrame.Angles(math.rad(updatedSprings.recoil.X), math.rad(updatedSprings.recoil.Y), math.rad(updatedSprings.recoil.Z))
			end
		end
	end
end

I’ve also managed to capture a moment when the parts correct themselves and lock back into place. (Don’t worry about the animation, it isn’t finished yet lol)

I have also noticed that the parts’ AssemblyLinearVelocity and AssemblyAngularVelocity are not 0, 0, 0, which might have a part in the problem.

It’s been a while, and I’ve started another FPS project and came across this same problem.

I’ve tried so many things, parenting the parts under the model instead of the folder, changing the CollisionGroup to default instead of Viewmodel, rerigging the entire gun, changing the size of the parts, and much more.

I’m a little desperate for a solution right now. I would really appreciate anyone’s help in diagnosing the issue here.

What I know
  • This bug only applies to essential components of the gun, like Fire or Aim
  • Parts are motored to the Main part just like any other part of the gun is
  • Parts suddenly correct themselves if you press the Windows key (???) I did this to check their positions. I noticed they would correct themselves when I pressed the Windows key
  • Blue dot showing origin/position stays in place, while the drag selector axes are going everywhere, but the position is actually following the selector axes
  • May/may not correct themselves after a little bit of testing
  • This bug seems to apply to the Aim part as well, however I can aim perfectly fine
  • I am 80% sure this is a bug on Roblox’s part

If you can see and provide any more details, please share them

Another bump. Still unsolved. I would really appreciate any help I can get.

you have to rig it with rig edit, and weld it as join instead of weld, maybe bc you haven’t join it so it fling around

I already use RigEdit.

…What? I’ll look into it, but what?

bc weld might have some bug when you use it, so use joint

Oh, right, yeah, I already use joints.

Any other possible solutions?

As I noted above, it’s unlikely anyone is going to be able to solve this until you can provide a minimum repro place file, i.e. an rbxl that has the bare minimum stuff in it for someone else to be able to run it in studio and see the bug happen (and be able to debug it, inspect relevant properties, etc.) Because there are both constraints and code possibly influencing the parts, it’s too complex a setup to be able to just guess what’s wrong or guess at how to reproduce your exact situation.

you can try to anchored the aim part, I usually anchored the aim part in my game

I just use Attachments for this sort of thing. Welds and Parts have unnecessary overhead. The only time it really makes sense to use an invisible part is if you need the bounds of it to defined the volume of a particle emitter.

Here’s a very basic repro file. (Ignore if you get flung, I couldn’t bother to add a separate collision group)

gun_bug_repro.rbxl (356.1 KB)

This is what happens when I play.

Another bump. The comment this one is replying to contains a repro file that could help solve the issue.

Fourth bump. Maybe previous comments can help.

@EmilyBendsSpace (I gave the repro file you requested above)
@C_Sharper
@devloperblox

1 Like

Your Viewmodel’s HumanoidRootPart is being CFramed on Renderstep to the camera, but you forgot to anchor it! That part is the root of the whole gun assembly, so you have to anchor it. What’s happening right now, with it unanchored, is your whole gun+arms assembly is in continuous freefall, accelerating every physics step due to gravity. You’re snapping it back to the camera location every Renderstep, but it’s still technically continuously falling during every physics simulation step and picking up speed. CFraming something is not a physics-sim aware action, so it has no effect on the velocities. This is why you see it have an ever-growing AssemblyLinearVelocity and AssemblyAngularVelocity on the whole assembly.

So just anchor that root part and your problems go away.

Also, it’s important to note that it’s totally normally for Studio’s dragger adornments to lag a frame behind rendering. They are not part of the game render update. You can ignore the jittery dragger arrows, they are not indicative of a problem with the part itself, Studio just doesn’t update them in sync with the render camera.

1 Like

It works! Thank you so much for the solution and in-depth explanation.

1 Like

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