Tweening twice (and delayed) after client replicating?

Hey! I’m just trying to replicate a tweened character (client → server → all of the other clients) but it is working weirdly: it seems to do the tween but twice (since tweened distance is doubled). But, as soon as I move the tweened character, it glitches and fixes its position on the spectator client.

I’ll show you (tween start position was the same line than the spectator client; left is original tweened character, right is just the spectator client; as you can see, it moved a whole square more than the original):

Local script (tween and remote parts):

function Tween(x)
	x.HumanoidRootPart.Anchored = true
	local Ray = Ray.new(x.HumanoidRootPart.Position, x.HumanoidRootPart.CFrame.LookVector*distance) --ray prevents tween from going through parts
	local Wall, HitPosition, Normal, Material = workspace:FindPartOnRay(Ray, x)
	local length = (x.HumanoidRootPart.Position - HitPosition).Magnitude
	local CFrameTween = TweenService:Create(x.HumanoidRootPart,
		TweenInfo.new(0.5,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut,0,false,0),
		{CFrame = x.HumanoidRootPart.CFrame + (x.HumanoidRootPart.CFrame.LookVector*length - x.HumanoidRootPart.CFrame.LookVector*2)})
	CFrameTween:Play()
	CFrameTween.Completed:Connect(function()
		x.HumanoidRootPart.Anchored = false
	end)
end

remote.OnClientEvent:Connect(function(tweened)
	Tween(tweened.Character)
end)

Thank you for reading, I’d really appreciate your help on this weird issue!

I believe it is automatically replicated… try it out and correct me if I am wrong.

1 Like

I also believe that, how can I fix it? Just doing the same tween but backwards or what?

Thank you for replying!

If we conclude that it is indeed automatically replicating, you do not need to manually replicate on all clients, and simply stick with the one original tween.

1 Like

I would have done that, but for some reason, the original tween isn’t smooth at all and has a huge delay.
Now, what should I do?

Thank you for replying!

Is the script you provided in the original post the original tween? I assume not.

1 Like

Yes, the local script I provided in the post is the one I’m actually using to tween the original character (it is the same script, I use the same function). Why are you asking this?

Thank you for replying!

What exactly do you mean? Does it start later than expected, but still provide the intended function?

1 Like

It has 2 big issues:

  1. Isn’t as smooth as I expect (I use Exponential + InOut in 0.5s; the automatically replicated one looks like a Linear + Out in 0.2s).

  2. It start way later than expected (but finish at the same time I think).

Thank you for replying!

Are you sure the issue lies within the local script and not the script that fires the event? Perhaps the event is just being fired late?

1 Like
  1. The script that fires the event is the same (it starts at this local script, then just go to a server script that simply redirects it to the other clients and then come backs to the same local script), so no.

  2. The manually replicated tween works just fine, but the automatic one doesn’t (which happens delayed, after the manual one).

There isn’t just a way to avoid the automatically replicated tween (if it is even a tween, because it looks like just an automatic position correction)?

Thank you for replying!

Why not fire from the server to all clients like this architecture (server → all clients).
This way, it wont be seen from the server but it will be seen from all clients.

1 Like

I’m doing exactly that (just avoiding it to see it twice by the original tweening character):

Server script:

remote.OnServerEvent:Connect(function(plr)
	Activated() --ignore this
	for i,v in pairs(game.Players:GetPlayers()) do --gets all players
		if v ~= plr then --checks it isnt the same player
			print(v)
			remote:FireClient(v,plr) --redirects the remote
		end
	end
end)

Thank you for replying!

I think you should just really be firing it to all clients and then you can do the tweening, instead of tweening it to the client first, and then firing it to all clients except for that specific player.

(try also testing it with 2 players)

1 Like

Now it happens (the double tween issue) in all of the clients (even in the original one), even though it is only called once (with the :FireAllClients call)

I already have been doing that.

Thank you for replying!

Are you performing the tween(s) on the client or the server? Tweens performed on the client will be smoother than tweens performed on the server.

2 Likes

As I said, I’m performing tweens from client (and replicating them to all of the other clients), but for some reason it happens two times (on the other clients; since it works perfectly on the original client): the first one (as it should, totally smooth) and a second one (not smooth and delayed).

Thank you for replying!

UPDATE
I confirmed my own theory: it is actually tweening twice. I tried using this module (which makes it easier to replicate tweens) and got a message on output “Canceled a previously running tween to run requested tween”, this means that another tween is trying to play (for no apparent reason).

Do any of you know why does this happen and how to fix it?

Thank you for reading!

Remove the replication entirely. Roblox should be automatically replicating it.

1 Like

As I told you before, the automatically replicated isn’t smooth at all and it is pretty delayed, so I can’t use that one.

Thank you for replying!