I am trying to make a throwing ball (the ball stops when it touches something), but the problem is that sometimes the ball stops before it touches something, I found that when this happens it is in the right position on the server-side but it is not in the client-side
I am using RocketPropulsion to move the ball to the target
local function FireMagicBall(EndPos)
local ball = game.ServerStorage.MagicStorage.MagicBall:Clone()
ball.Parent = workspace
ball:SetPrimaryPartCFrame(tool.Shoot.CFrame * CFrame.new(0, 0, -2)) --put the ball in front of player
print(mouseHit)
ball.PrimaryPart.RocketPropulsion.TargetOffset = mouseHit --set the target of the ball to the mouse position
ball.PrimaryPart.RocketPropulsion:Fire()
end
You should consider having the client that fired the projectile control network ownership of it. This will improve server performance by allowing it to replicate less network information and may make the projectile feel better. Just be careful with the security implications involved with this as a client could change the course of the projectile.
You can change this with a small snippet of code (Set network ownership before it starts moving):
Hi,
thank you, everything is working fine but I can’t think about a solution to prevent the exploit problem, the client can change the speed and a lot of things to the body mover they can even create a new one, is there any solution for that?
Unfortunately, this is a problem with client raycasts/projectiles. The best you can do is sanity checks when processing server hit information. (Where did the projectile come from, where did it end, is the path between the two clear?)
There is not much else that can be done if you are looking for both performance and user experience to be prioritized.