RotVelocity, Velocity, Position, Orientation inaccuracies

FirePoint is the part selected in the gif, at the tip of the gun. Visually, it is unmoving. However, whenever i try to fire, the bullet comes form a seemingly random direction. After researching the problem for a bit, I found this:

The gun in question is a rigged model that is attached to the camera (through RenderStepped). None of my other guns do this. Another demonstration of the seemingly broken and wrong position readouts:

I am beyond confused. I’m not sure what code is causing this, but heres the script that keeps the gun on the camera, incase it might be some help.

game:GetService("RunService").RenderStepped:Connect(function()
	if game.Workspace.WeaponPreview:GetChildren()[1] then
		local gun = game.Workspace.WeaponPreview:GetChildren()[1]
		if char[gun.Name] then
			if char[gun.Name]:FindFirstChild("Aiming") then
				if not char[gun.Name].Aiming.Value then
					pos = game.Workspace.CurrentCamera.CFrame*CFrame.new(char[gun.Name].Offset.Value) * CFrame.Angles(math.rad(char[gun.Name].PosRotation.Value.X),math.rad(char[gun.Name].PosRotation.Value.Y),math.rad(char[gun.Name].PosRotation.Value.Z))
					gun:SetPrimaryPartCFrame(pos)
				else
					pos = game.Workspace.CurrentCamera.CFrame*CFrame.new(char[gun.Name].AimOffset.Value) * CFrame.Angles(math.rad(char[gun.Name].PosRotation.Value.X),math.rad(char[gun.Name].PosRotation.Value.Y),math.rad(char[gun.Name].PosRotation.Value.Z))
					gun:SetPrimaryPartCFrame(pos)
				end
			else
				--its a tool
				pos = game.Workspace.CurrentCamera.CFrame*CFrame.new(char[gun.Name].Offset.Value) * CFrame.Angles(math.rad(char[gun.Name].PosRotation.Value.X),math.rad(char[gun.Name].PosRotation.Value.Y),math.rad(char[gun.Name].PosRotation.Value.Z))
				gun:SetPrimaryPartCFrame(pos)
			end
		else
			gun:Destroy()
		end
	end
end)
1 Like

Try anchoring the FirePoint or setting its Velocity to (0, 0, 0) every RenderStepped.

I think it happens because even though you set the position every frame, the Velocity just keeps growing and growing until the FirePoint can reach a height of -50000 in a single frame and gets destroyed.

I’m quite confused about this code. How are you setting the position of the fireplace? Are you using WeldConstraints?

The firepoint is welded to the gun, in a model. The model is moved onto the camera every render step using :SetPrimaryPartCFrame.

Thank you very much, while I may not know whats causing the velocity to freak out, we do know what fixes it! Thanks! :smile:

I can’t have them anchored since that would break the animations, but setting the velocity to 0 fixed it just fine.

1 Like

Keep in mind RootPriority should be higher in whichever part of the weld connection you want to be the main handle. So in this case, the firepoint should have a lower RootPriority.

1 Like