I’m currently working on a train game that requires trains to be moved smoothly and synced between clients.
My current method is that the server sends all clients info about a train movement, then each client uses tween service to move the train. Below is the function I use to tween a model to a certain position.
function TWEENMODEL(model, cframe, pause, style)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
if model ~= nil then
if model.PrimaryPart ~= nil then
model:SetPrimaryPartCFrame(CFrameValue.Value)
end
end
end)
local tween = game:GetService("TweenService"):Create(CFrameValue, TweenInfo.new(pause, style), {Value = cframe})
tween:Play()
return tween
end
This has worked well for this game and many previous. However, in recent tests I have occasionally been getting the following message in the server output
(‘MT’ is printed server-side whenever a train movement event is sent to the clients. I am not sure if it is linked to the issue)
This message is very confusing as my game does not use any animations / humanoid animations of any kind.
I can only think of two causes for this:
-
Tween service is possibly connected to animations and therefore I am accidentally playing 256+ tweens on the same model (I tried to reproduce this but did not get the error) The issue seems to happen when i’m in game for a long amount of time. Maybe once 256+ train movements have happened?
-
It’s something to do with my player model and an issue on Roblox’s end.
I’m finding it incredibly hard to reproduce and it’s especially weird as this is in the server output, when all tweening is done locally.
Any advice would be appreciated.
EDIT
I had the idea of disabling all trains and waiting until all tweens have stopped. The message is stiill being printed twice in chat every two seconds. Nowhere server-side in my game do I have any loops with a 2 second delay. Also for extra info, I had 4 trains running in the game at the time, so the message printing twice does not make sense either.
EDIT #2
I just found this lad on my map used for scaling, who I completely forgot about. It has an animation script inside and would make sense to be causing this problem. I’ll remove it, do some more tests and see if the problem persists.