Projectile teleporting on client side

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to optimize client-sided projectile so it doesn’t instantly teleport to the target

  2. What is the issue? Include screenshots / videos if possible!
    Projectile going instantly to its destination on client side, while server looking perfectly fine.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried adding delay with task.wait() before the axe weld to the part it hits, but it made it even worse

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

On the videos i added you can see client and server sides of view.

--Collision		
			local projectile = axe:Clone();
			projectile.Parent = game.Workspace;
			projectile.CanCollide = true;
			projectile.Blade.CanCollide = true;
			projectile.CanTouch = true;
			projectile:FindFirstChildOfClass("WeldConstraint"):Destroy();
			projectile.Velocity = root.CFrame.LookVector * 100 + Vector3.new(0, 10, 0);
--Sticking to the part it hits
collisionconnect = collision.Touched:Connect(function(part)
				if (not part:IsDescendantOf(collision.Parent) and part.CanQuery == true and part.Name ~= "Handle") then
					axe.CanCollide = false;
					blade.CanCollide = false;
					
					stickweld = Instance.new("Weld");
					stickweld.Name = "StickWeld";
					stickweld.Part0 = collision;
					stickweld.Part1 = part;
					stickweld.C0 = collision.CFrame:Inverse();
					stickweld.C1 = part.CFrame:Inverse();
					stickweld.Parent = collision;
					
			        collision.Velocity = Vector3.new(0, 0, 0);
					
					collisionconnect:Disconnect();
				end
			end)



Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

This looks like you are doing a lot of fancy visual effects on the server side, which you really, REALLY, will want to keep on the client side for the sake of preventing events like this.

I made the same mistake a few months ago, and changing the visuals to be purely client was the fix for an issue like this one.

The easy way to think of it is, no one sees the server, so you could make the axe teleport on the server side, and do your cool looking effects on the client side, and it would be awesome, and faster!

I don’t think its the effects, those are basic roblox trail and emitter, I’m not sure how to make client only emitters. Anyway i found out issue is the weld that happens when axe sticks to the part it hits, still didn’t find a way to fix it though

When you clone the projectile, try initializing its CFrame similar to that of its intended CFrame.

Tried that,

projectile.CFrame = axe.CFrame;

didn’t do anything, also i noticed that axe flying smoothly when there no obstacles on its way

It might be a delay issue. When you clone it and set it to axe.CFrame, in the server, that’s probably where ‘axe.CFrame’ is. Instead of that, try setting the cloned projectiles CFrame manually to its intended position. So manually fix it on your characters hand

projectile.CFrame = root.CFrame + root.CFrame.LookVector * 10;

doesn’t seems to affect anyway

--Collision		
local projectile = axe:Clone();
projectile.Parent = game.Workspace;
projectile.CanCollide = true;
projectile.Blade.CanCollide = true;
projectile.CanTouch = true;
projectile:FindFirstChildOfClass("WeldConstraint"):Destroy();
projectile.CFrame = root.CFrame -- Change
projectile.Velocity = root.CFrame.LookVector * 100 + Vector3.new(0, 10, 0);
--Sticking to the part it hits
collisionconnect = collision.Touched:Connect(function(part)
    if (not part:IsDescendantOf(collision.Parent) and part.CanQuery == true and part.Name ~= "Handle") then
        axe.CanCollide = false;
        blade.CanCollide = false;
        
        stickweld = Instance.new("Weld");
        stickweld.Name = "StickWeld";
        stickweld.Part0 = collision;
        stickweld.Part1 = part;
        stickweld.C0 = collision.CFrame:Inverse();
        stickweld.C1 = part.CFrame:Inverse();
        stickweld.Parent = collision;
        
        collision.Velocity = Vector3.new(0, 0, 0);
        
        collisionconnect:Disconnect();
    end
end)

Try setting the network ownership of the projectile to the player.

1 Like