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):
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!
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.
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?
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.
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)?
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.
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)
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.
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)
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).
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?