Part keeps falling even though rigged correctly

So I am making an FPS game and the bullets are controlled with raycasts. The problem is that the start or origin of the ray for some reason keeps “falling”.
image

Here is how the end part is rigged:

image
image

And here is a visualization of it “falling”.

I really don’t know the cause of this, but it might be because of the changes I made in my script. Any help would be appreciated!

1 Like

I think it’s a camera glitch, check any of the modifications you made to the camera

ok i will check right now and see if that is the case of the problem.

Could we see the code where you fire the raycast?

ok. here is my code for the raycast. i’m pretty sure this is not the problem though.

local params = RaycastParams.new()
	params.FilterDescendantsInstances = {p.Character}
	params.FilterType = Enum.RaycastFilterType.Blacklist
	
	local result = workspace:Raycast(s, (e - s).Unit*d, params)
	
	if not result then return end
	
	print(result)
	
	coroutine.resume(coroutine.create(function()
		local clone = script.Parent.Parent.Part:Clone()
		clone.Parent = workspace
		clone.Position = result.Position
	end))
	
	local hum = result.Instance.Parent:FindFirstChild("Humanoid")
		
	if hum and hum.Health > 0 then
		hum:TakeDamage(20)
			
		if hum.Health == 0 then
			print("KILLED: "..result.Instance.Name)
		end
	end
		
	return result.Position

yeah i don’t think its the camera. All i did was just change the FOV to aim the gun, nothing with the CFrame.

Hmm it doesn’t seem to be the issue as you said, I don’t really know what the problem is, in the video it shows that everytime you shoot/click it changes position, maybe it has to do something with that?

yeah I have a script that finds the position of the tip of the gun and uses that as the origin of the ray, which is why I think the tip of the gun keeps “Falling”.

function tool:shoot(toshoot)
	--check once again if weapon
	if self.tag ~= "weapon" then return end

	self.shooting = toshoot
	
	--fires ray everytime self.shooting
	if self.shooting then
		--checks
		if not self.shooting then return end
		if not self.isequipped then return end
		
		--play animation
		resume_cor(create_cor(function()
			self.shoot_anim:Play()
		end))
		
		print(self.model.muzzle.Position)
		
		--invoke server to do raycasting
		local h = shoot:InvokeServer(
			self.model.muzzle.Position,                          --start
			self.model.muzzle.Position + cam.CFrame.LookVector,  --end
			200                                                  --distance
		) 
		
		wait(.7)
	end	

end

its really simple and i’m not getting any major bugs so its probably not the problem

UPDATE TO PROBLEM:

So I printed out the Y-value of the position of the tip of the gun using renderstepped and it turns out it isn’t falling. This means that the culprit must be when I pass the arguments to the server. I will check and if so, I guess I have a solution

1 Like

FINAL UPDATE

Yes, I solved my problem! The muzzle position in the shoot method was different than the muzzle position in renderstepped. So, I just made a new object called origin and used that as the position in the shoot method instead of the muzzle position. Now it works!