Knife Vanishing way before it actually hits the target

The issue is summed up by this video:

The knife’s network owner is nil. Its not due to network ownership (i think).

I’m fairly certain that I will have to make knife projectiles on the client, how can I accomplish this for it to appear smooth for everyone? How can I make the client projectile sync up with the server detecting damage?

Knife Damaging Code
if damaged then return end
						local partsTouchingKnife = workspace:GetPartsInPart(knife, OP)
						if partsTouchingKnife[1] then
							local hit = partsTouchingKnife[1]
							if hit.Parent:FindFirstChildOfClass("Humanoid") then
								dealDamage(hit, (15 * standData.DamageMultiplier), false, true, bv.Velocity.Unit, "Knife", {BrickColor.Red(), "Hit"})
							end
							
							damaged = true
							knife:Destroy()
						end
2 Likes

what i am about to say sounds really stupid but have you tried adding a wait in between these two to see what happens when you delete the knife per say 0.5 seconds later

1 Like

You could consider using raycasting for this, and move the projectile accordingly until it actually hits something.

Tried this already, using forces was my other idea since the raycasting and stuff just wasn’t working too good and it looked horrible.


Ehh not quite what I wanted. It also looks pretty bad at close range:

Have you tried fine tuning it more such as wait(.01) or wait(.25). Otherwise yeah do something with raycast

I have, it just gave pretty similar results.

I’m hoping I can figure out a way to just simulate the knife on the client so it won’t be choppy but I’m not sure how complicated that will get. I might have to try raycasting again

Yeah, I would highly recommend that you try raycasting it again as the other person previously said.


Utilizing raycasting + body velocity I was able to get a pretty decent result that isn’t as bad as before.
All I did was cast a ray in the direction of the knife every frame while the knife was traveling to check if it had hit anything yet. If it did, teleport the knife directly to the hitposition of the ray, make it invisible and use the body velocity from earlier to lock it in place. Then just delete it a couple seconds later using debris. Once I increase the knife speed it shouldn’t be so obvious that it teleports.

However due to me using raycasting now sometimes the knife goes right through them and misses the hit detection entirely. This was happening before when it was purely raycasting and not physics.
Fixed by increasing the ray length by a bit.

That definitely looks a lot better than it did before, are you satisfied with that result or do we need to figure something else out?

I mean it isn’t that good but it also isn’t that bad either. If I can find a good way to make client projectile knives then that is what I am 100% going to do. Is there any ideas on how I can get the knife (on the client) to sync up with the damage on the server fairly well?


I did it!


All I had to do was examine how the throwing knife tool did it so smoothly. Instead of relying on physics or raycasting, just set the knife’s velocity and cframe it to the right position every frame. Then when it hits something just weld it into place rather than anchoring it. No client stuff involved!


task.spawn(function()
				repeat
					if not gameEffects.TimeStopped.Value then
						distanceTraveled = distanceTraveled + 1
						
						knife.CFrame = CFrame.new(knife.Position, knife.Position + knife.Velocity) * CFrame.Angles(math.rad(-90), 0,0)
					end

					if distanceTraveled >= 300 then
						knife:Destroy()
					end

					task.wait()
				until (knife == nil) or (damaged == true)
			end)
3 Likes