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.
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?