Hello everyone!
Lately I’ve been experimenting with projectiles in studio. I use BodyVelocity to move then and .Touched to detect if they touch any of the specified targets.
This is the code I wrote:
script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player, arg)
local part = Instance.new("Part", workspace.Effects)
part.CFrame = Player.Character.HumanoidRootPart.CFrame
part.Shape = "Ball"
part.CanCollide = false
part.CFrame = CFrame.new(part.Position, arg.p)
local bv = Instance.new("BodyVelocity", part)
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = part.CFrame.lookVector*100
part.Touched:Connect(function(hitPart)
if hitPart.Name == "Wall" then
part.Anchored = true
bv:Destroy()
end
end)
end)
The event is fired successfully, but the problems come when the projectile created hits it’s target.
This is how it looks on the client when the projectile hits something:

And this is how it looks on the server when the projectile hits something:

I tried raycasting to determine the exact position of where it should be when the projectile touches something, then move the projectile to the hit point of the ray, but it doesn’t always work. Are there any better ways to create and move projectiles?
Any suggestions or possible fixes are welcomed.
Thank you for taking your time to read my post!

