TweenService V2

print(settings().Network.ReceiveRate) --> 60
3 Likes

If someone disconnects for a second, it wont re-send the event call, since the tween is running clientside it would continue running. However, there isn’t anything in place to stop the client missing the tween request event while they are disconnected for that split second if that’s what you’re asking.

1 Like

What I mean is are the tween signals time-stamped so if one signal is delayed and they arrive non-chronically it handles it as expected.

1 Like

I know I feel pretty stupid lmao

1 Like

This kind of information doesn’t have an obvious location to search for on the wiki, sometimes you can only know of their existence by doing experiments on your own.

Not all parts replicate at the same rate, see ReplicationFocus. If you’d like to know the current rate of a part, you can use the ReceiveAge property, because you can get the time it was updated.

4 Likes

Just released an update on both the github and the file download - a new function called ‘QueuePlay’. Docs:

Tween:QueuePlay(Yield [Boolean, optional], Player [Player Object, optional])

Add the tween to a tween queue which will start playing the queue automatically immediately after the previous tween on that instance completes. Behaves exactly the same way as Tween:Play() once started, except the initial firing of the tween is managed on the client. For this reason, best practice is to fire this event as close to when you would like it to be played on the client to maintain alignment between tweens. If fired multiple times in a short time frame, this may result in clients becoming out of sync over time.

Here it is in action (clientside), the red dots represent server side requests for queuing of a tween, and each tween is set to take 2 seconds. The dots build up as they are created once a second, while the tween takes 2.

The reason I added this is that if you want zero latency between tweens, this function provides that. Simply call it anywhere between when you start the first tween, and when you want the second tween to start, and it will start pending clientside, therefore when the first tween finishes, the second one instantly starts clientside without network lag.

5 Likes

This new function should fix that.

1 Like

If I was to tween a SpotLight in its range, is it still possible to get it as smooth as if it was on the server.
I’m struggling to make it smooth using the module.

1 Like

Theoretically this should be more smooth than server side tweening in some cases, could you send your code?

2 Likes

Are we able to use the .Completed Event with this module?

2 Likes

Hi, no this isn’t part of the module. I might add it in future , didn’t think about it when making it since I rarely use this property myselfm

These changes are definitely useful!

I am not sure this is working properly. I followed the setup in the video but i get an error:

this seems to be because the module is trying to create a RemoteEvent but it never gets created and the client then hangs up when the WaitForChild cannot happen

These are the first lines of code in this module that should be doing that, but they dont do it.

local module = {}
local tService = game:GetService("TweenService")
local rService = game:GetService("RunService")
local tEvent

if tEvent == nil and rService:IsServer() then
	tEvent = Instance.new("RemoteEvent", script)
	tEvent.Name = "TweenEvent"
else
	tEvent = script:WaitForChild("TweenEvent")
end

Anyone know why this wouldn’t work as it says it should? The code looks good to me, why wouldnt the RemoteEvent be created?

Are you calling the module both client and server side?

1 Like

I definitely was. The error is from the client not finding the event when doing the waitforchild.

When running I studio, the server-side module never creates the event. I checked and it isn’t there during test, hence the error being thrown from the client side.

Sorry I can’t test further, I have since removed the code.

1 Like

This is a really cool module.
I might use it for my RPG game, however, I have an hypothetical scenario that I’m curious about.

To explain this scenario, I have drawn this highly detailed comic:


Basically, a red guy throws a fireball spell and a green guy protects himself with a shield spell.

The collision itself would be detected on the server side and the tween would have to stop mid-way before reaching the target.

What happens if the client side lags and doesn’t get the memo to pause?
When it eventually receives the message to pause, does the fireball rewind itself back before pausing, or does it just freeze where it is?

1 Like

The module is essentially a proxy for clientside tweens, so the behaviour here would be the same as it would be were you to send your own event to the client which then triggered the tween on the client. I don’t think you are doing this here, but make sure not to use the module for any kind of competitive game mechanics, due to the latency problems you mentioned.

The module doesn’t have a fail-safe to make sure that the client has received the event, so I suppose in edge cases with very bad internet the tween could continue without being paused.

1 Like

I hate necrobumping topics, but I have a question. Is there a way to wait for the tween to finish on the server? Is there some kind of event that I have to wait for in order to know when the tween is finished?

1 Like

Any chance you’re planning on adding this? I personally find .Completed really useful as I often make things happen after the tween ends and check the PlaybackState, although I’m not sure how you’d implement this as the tweens finish at different times.

2 Likes

That’s something .Completed would be useful for (you could for example do Tween.Completed:Wait()), but the module sadly doesn’t have this so I’m not sure if it’s possible at all. If you do find/have found a way though, please let me know as I’m currently trying to do the same.

1 Like