BodyVelocity Projectiles?

For a spell casting system, I’m having an issue with the spell part itself. Server side (and play solo of course) it works fine and as expected (for the most part), however the client has an issue with it. On the client, it shows the spell part going forward a bit, then moving to the opposite direction, before resuming. Except the server registers a collision by then, and the part is anchored.

Client

https://gyazo.com/bcea2fc07ca85eace2fb7175f0690792

Server

https://gyazo.com/ca25915850ad1a68fb8ec7a0234aa076

Taking advice from a friend, I set the network owner for the part to the server (nil). But that, unfortunately, didn’t really change anything.

At some point, I plan on moving the (anchored) projectiles manually using CFrames, and raycast every so many often to check for a collision. However, before that point, it’d be nice to fix this small problem. I’m thinking I probably have to tell the clients to create the projectile (and other particle effects) from the server rather than just have the server create the part, but wouldn’t that result in a delay between the spell and the effects when a spell collides with something?

Code Summary
local spell_part = trail_part:clone()
spell_part.Name = "Spell"
spell_part.CFrame = CFrame.new(player_tool.WandTip.Position,mousePos)
spell_part.Size = Vector3.new(1, 1, 1)
spell_part.Transparency = 0
spell_part.CanCollide = false
	
spell_part.Parent = workspace
spell_part:SetNetworkOwner(nil)

local bodyV = Instance.new("BodyVelocity")
bodyV.Velocity = dir * 200 * (1+getDamageMultiplier(player_tool)/10)
bodyV.MaxForce = Vector3.new(1,1,1)*1000000
bodyV.P = 10000
bodyV.Parent = spell_part

On a side note, why is the part and trail starting so far from the wand? The code should position it at the tip of the wand, but that obviously doesn’t happen. If I anchor the part the moment it is generated, then I can see that it does indeed start at the correct position. Is it because the BodyVelocity acts before the part is rendered?

A lot of games do what you described - making the projectiles on each client and sending them data about it every so often to update it.
Check my post I made here about this exact topic.

Also, I ended up using TweenService to move my projectiles, but it can be a bit finicky right now.
Good luck!

3 Likes