Client sided projectile's body velocity won't work on other clients any fix?

This is my first post on the forum so sorry if it’s not up to the standards

I’m making a client sided projectile and I’m having trouble with the body velocity this is the error I get: attempt to index nil with ‘Hit’
And this is what happens: https://gyazo.com/10243f8826e6d370a585c2e717a000a7

I’m trying to make the projectile shoot from the person who shot the fireball’s mouse but I have to update the mouse position

I’ve tried a lot but nothing works I’ve also tried looking for answers here and other places but found nothing

If you need any more code don’t hesitate to ask

This is in a local script just so ya know

local mouse = plr:GetMouse()
2	 
3	local bv = Instance.new("BodyVelocity")
4	bv.Name = "FireballBv"
5	bv.Velocity = mouse.Hit.lookVector * 100
6	bv.MaxForce = Vector3.new(1e8,1e8,1e8)
7	bv.Parent = Fireball

Help is very much appreciated :slight_smile:

The server has no business rendering effects. The server should primarily process data. Anything visual should be managed by the client.

  1. Have the client that is casting the ability :FireServer() their mouse.Hit.p.
  2. Make the server sanity check however you want to, then :FireAllClients() the sanity-checked position and instructions to make a fireball, or whatever projectile you’re trying to make
  3. Clients will receive the instructions and position and replicate the projectile properly

Keep in mind that you will need to make a good system that accounts for latency for players with poor connections

I tried doing that but my problem is I need to update the mouse position

So wait, it follows the cursor? You’ll want to have something that keeps track of active fireballs on the server and another remote that will update the velocity accordingly. You should also make sure the mouse doesn’t count the Fireball when hovering using TargetFilter

No I have 2 fireball attacks one shoots 6 fireballs and the other one shoots a fireball after 1 second or so so if I were to send the mouse position once all the 6 fireballs would all shoot the same direction and if I were to shoot the normal fireball and you moved your mouse before the 1 second has passed you’ll shoot it in the direction your mouse was once you shot it

I don’t think you have to do the waiting on the server? You only have to create the fireballs on the server, not all the waits and stuff.

You can fire a remote 6 times from the client, and fire the big fireball from the client after a 1 second wait on the client.

1 Like

Making the projectiles will just cause lag so I make them on the client but I’ll try what you suggested

Worked perfectly thanks! I’ve had this problem a lil while

1 Like

You should set network ownership to the player firing the projectile as well, this will avoid spikes in the projectile. This can be done with a server-script.

Use a localscript to get the mouse and whatever you need, then let the server-script know when to fire and give the player network ownership.