Hello, lately I’ve been working on my own project and decided to rotate locally the plants to face the camera to give a neat 2d-ish effect like so :
This is the Client :
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/f/0/5/4/f05449dec40c235a1b073754d5f2569599aa2929.jpeg)
This is the Server :
![image](/secure-uploads/uploads/original/5X/7/2/3/9/7239e3057e0520f5612424de36c36a05cdfd546d.jpeg)
But then another problem comes! The projectiles from the plants don’t line up!
Projectiles shot from the Client’s view
Projectiles shot from the Server’s view
Help would be much appreciated! I’m not that good at scripting, so I’d love if someone told me what I’d have to do.
2 Likes
I always do this for projectile: on the server, they’re an invisible part with a LinearVelocity, while on the client they’re a meshpart actually shaped like the projectile, with the same size as the server’s projectile and the same VectorVelocity on a LinearVelocity. When the server projectile is destroyed I also destroy the client one.
Remote.OnClientEvent:Connect(function(serverProjectile)
if serverProjectile == nil then return end; -- in case the server projectile was destroyed before the event could reach the client
local clientProj = ReplicatedStorage.Projectile:Clone();
clientProj.LinearVelocity.VectorVelocity = serverProjectile.LinearVelocity.VectorVelocity;
clientProj.CFrame = serverProjectile.CFrame;
clientProj.Parent = workspace;
Debris:AddItem(clientProj, 30); -- in case the AncestryChanged event somehow fails, so the projectile doesn't exist forever
serverProjectile.AncestryChanged:Connect(function()
if serverProjectile.Parent == nil then
clientProj:Destroy();
end;
end);
end);
^ keep in mind this is a code I wrote just now, you’ll obviously have to change it to fit your game.
5 Likes
Like what LocalPlayer said, you should have the client render their own projectiles.
1 Like