TweenService Plus+ [Update V1.1]

This graph also doesn’t depict what this module does correctly. It’s misleading. This is a better representation of what the module does looks like in a graph.

Here, I’m using an In Quad curve. The formula to construct a graph that describes what the module does here would be:

image
(for an InQuad curve)

Where c is the change of value in the tween, t is the current time, d is the duration of the tween, and l is latency. This equation just allows all of the graphs at the equation to always intersect (end the tween) at the same x value, which is time. This is what this module does with client latency compensation.

In any easing equation (for different easing styles) it’s the same thing. Easing functions require 4 things: a start point, change in value, duration, and current time. So, using this concept with any easing equation would mean that

  • start point = server start point + latency
  • duration = server tween info duration - latency
  • change in value = whatever the server is tweening to
  • current time = always a moving time-based value like tick()

Y axis is change, X axis is time

The server tells client 1 and client 2 to run a 3 second tween, and move a part 2 studs up.

The blue tween is client 1, who will have no latency for the sake of this. The green tween is client 2, who has .5 seconds of latency which is why the green graph is translated a bit to the right (it means that it starts after client 1).

As you can see, they finish at the same point at the same time. This is what the module is supposed to do.

Here, I’ll apply 1.5 seconds of latency to client 2.

As you can see, they still end up at the same place at the same time.

No matter how much latency you apply, they will end up at the same point at the same time. This is the “client latency compensation” being done here.

5 Likes

Yes, that was my point. I know the whole purpose of using this module is to account for latency, but, some people might use this for obbies and if theres a noticeable gap between the actual position and the position on their screen, they might see it as unfair:
image
Noticeable gap

3 Likes

I just explained why there’s no “actual position.” Nothing is happening on the server. Every client has their own local position, which is what you’re pointing out, and is what I’ve said multiple times already. This module is for things that do not need to be at the same place at the same time for the whole tween, and only need to end at the same place at the same time, like a door for example, or for tweening atmosphere colors. (Which is some of the things I’m using it for right now). And you shouldn’t use this for obbies where a moving platform would need to be in the same place for everyone at the same time on everyone’s screen.

And I’m going to repeat this again, for 85% of the time the graphs will be almost exactly the same because normal ping is 1-200 ms. Which is .2 seconds and under. I’m just explaining what happens with bigger latency

2 Likes

This does not work for me. I’ve converted a server tween to use your module, and upon playing it to all clients within 500 studs, the tween doesn’t play for the time allotted in the info, but it just suddenly puts the Part into the specified goal position.

2 Likes

Any errors or warnings? Also can I see some code/ an explorer setup? Weird, cause it still works for me. Also make sure you have the latest version cause I fixed a small bug a few days ago.

Edit: Also make sure you’ve set it up right. You have to require it somewhere in a LocalScript, and my assumption right now is that you haven’t done that part so you’re only seeing what the server is doing (one instant change) since the client side isn’t set up. Also make sure this module is in ReplicatedStorage

2 Likes

Thank you for your reply, I had saved this post from another day and forgot that you had to require the module in a client-side script, which explains my issue. My apologies.

2 Likes

@rek_kie Very nice module here! I have a small question though:

While I understand that the module essentially waits for client to finish the tween animation and then makes the server part the final size, is there a way to make it so that the part on the server is instantly the maximum size so that the client is just doing the tween for aesthetics?

My use case uses the touch event on the parts (via server script) and it detects other players a bit too late as the parts initial size is (1, 1, 1) and then instantly jumps to (100, 100, 100) 5 seconds later.

This is one of my first posts on the dev forum so sorry if I’m posting in the wrong format or something!

1 Like

Thank you! There isn’t actually isn’t a function for this in the module, though, because I wasn’t really thinking that people would have a use case for it. But, if you want it, I can add it, no problem.

Expect an update soon :upside_down_face:

1 Like

I look forward to it! :smiley:

Extra: I don’t know if this is too complicated to create but functionality where instead of having the part on the server start from the start size and then jump straight to the end size, maybe a way to have the part on the server change size as frequently as the developer needs?

For example if you want a part’s size to tween from (1,1,1) to (100, 100, 100) in 10 seconds, the developer would input how often the server should update the server part’s size. So if a step of 0.5 is used then this means that at the 5 second mark of the tween (because 10*0.5 = 5) the server part has it’s size updated to be half the size of the final size (50, 50, 50). If the step was 0.2 then every 1/5th of the 10 seconds (the tween time given) the server part size is updated to what it should be.

I know with this plugin you’re trying to mitigate lag by having as little changes as possible to the part on the server, but having this option might give more reliability to the module if touch events are involved so that things can collide more accurately! This is just an idea and idk how hard this would be to implement!

1 Like

I’ll probably get around to updating this pretty soon!

I’m a lot less busy and have some free time so stay tuned.

1 Like

Hey there, great module so far, going to be extremely useful for optimization if I can get it working right. Thus far I’ve been able to implement it as a replacement for most of my tweens, however I keep consistently running into an error I’m having problems debugging. It seems to occur only when the Reversed value is true and has been happening whether I tween the CFrame or Position, though I havent tested if it happens when reverse is true and tweening any property.

Error: Error

Module Code In Question: ModuleCode

My Code In Question: Code

Any ideas? So far it definitely seems to root from having reversed enabled and from the module itself as tweening the cframe with the module using my code works fine so long as it’s not reversed, however I don’t have the time tonight to get to the root of the cause and it wouldnt surprise me if its something on my end.

1 Like

Yeah there’s probably a bug with reverses. I personally don’t use reverses so I didn’t really test that part fully. I’ll look into it and get back to you

1 Like

@TimesIllusion fix the reverse issue, right after if info.Reverses then add startProperties = {}. The issue is that you are trying to add members to a variable that is not a table, so we make it a table before we add to it.

3 Likes

This is great, thank you! :smiley:

1 Like

Could you give us a sample code using the tween range feature?

1 Like

After you’ve created your tween:

tween:Play(nil, 150) -- plays the tween for people within 150 studs of the object

The first argument is an optional table of players to exclusively play the tween to, setting it to nil plays it for everybody (in this case within 150 studs)

Hello, I was planning on using this module for tweening welds but with the range feature. The problem I’m finding is since it needs a part to base the player’s position from I’m not able to set the C0 in goals. The weld is a child of the base part. Any help would be appreciated.

1 Like

MainObject feature is exactly what you’re looking for

Oh didn’t see that, thank you.

1 Like

oh wow thanks! I never thought of using “nil”, I kept on getting the error that integer isn’t “player”.

1 Like