How i can reduce lag in a soccer ball

Im currently working on a soccer game and i had problems, the ball react goes really good and i din’t had any issue with that, but i invited a friend who had spikes and he totally lagged the ball, the ball teleported to his leg or teleported at the place he wanted (Trying to explain i use Foot.CFrame.Lookvector), im still trying to stop this issue because i want to make my game available for everyone.

I still have this issue, i tried to refresh the ball CFrame every time a react event get fired, worked but when the event is not firing the ball is laggy as hell, i tried using a value to compare it with ball cframe and dint worked, the ball cframe only changes in my friend client, i tried too many mathods like incrementing ball size or making less force on VectorForce but i still having the issue.

Someone can help me?

1 Like

That’s quite interesting dilemma you have, but the solution to your problem is easier than you think.

I’ll explain how you can make a better soccer script in pseudo-code:

Check for some input on the client. (Let’s say left click with UserInputService,
Fire a remote event on the server, and play a kick animation when the remote fires.
Fire a raycast from the player’s “HumanoidRootPart” and check if the value of the ray’s hit is called, “Soccerball” or whatever you want to your soccer ball.

If a ray hit the ball create a body velocity and add it using the “Debris:AddItem()” function.

That’s pretty much how I’d do it, and I doubt that any lag would happen, if you need help just ask.

Good luck with that soccer game and never give up! :grinning:

4 Likes

I use Debris:AddItem() in a module, as Module.BallForce, i use VectorForce and BodyVelocity but nothing changes, ball goes lag when the react event is not fired.