Velocity not applying to Character sometimes

So i have this part of my shooting code

pcall(function()
					if hit.Parent:IsA("Model") then
						hit.Parent.PrimaryPart.Velocity = workspace.CurrentCamera.CFrame.LookVector * 12
					end
				end)

that knockbacks the character a bit when shooting at him the thing is when i shoot at the character it doesnt work (and when not using pcall it doesnt give errors) but after pushing the character a while it starts working and i have no idea why here a video about it

External Media

Edit: this code runs inside a module that runs the hit detection locally i believe

1 Like

Haven’t seen the video but you can use LinearVelocity or BodyVelocity instance instead.

Also I wouldn’t do hit detections locally because it’s easily exploitable, however the issue could be that it doesn’t detect the hit object at all.

It does since it sends the the damaging re to the srv and damages it correctly also i alr tried that and didnt work

1 Like

That’s strange, have you tried debugging it with print? Maybe print the hit.Parent

yeah everything works correctly in my believes still i think it works well now for any strange reason ill be investigating about it ty anyways

1 Like

Haven’t tested it yet, however it could be because of Network Ownership. Does the rig happen to freeze in place whenever you get close?

yeah it happens sometimes he even falls without touching him etc

1 Like

Try setting the Network Ownership to nil or to the player? Hope this fixes it!

How should i do that im not rlly into netwroking stuff at all yet lel

1 Like

Sorry for replying so late! For some reason I don’t get notified. Anyways the code is :SetNetworkOwner(nil).

Pretty sure you have to use a for loop to get the baseparts of the rig.