[UPDATED 12/7/20] Advanced Server to Client Tweening Module For Beginners

(UPDATE 12/7/20)
  • Added more features and documentation such as :Destroy() and :Cancel()

  • Cleaned up code for readablility

  • Optimized Code


Hello Developers!

As my first open source script, I made a module that allows you to easily turn a server tween into a client tween! Along with this, this module contains useful extra features that you can toggle. This was made to be easy to use by all skill levels with commented code to be easy to modify.

“What is client tweening and why should I use client tweening over server tweening?”

  • Client tweening is using TweenService on the player’s computer instead of the server to render the motion.

  • Client tweening is visually smooth even on extremely large games

  • Helps take the load of tweening off the server.

“I’m a advanced developer and know how to use client tweening, what use of this is to me?”

  • This module removes the issue of client syncing (Players not seeing the same thing because of ping) through speeding up the tween depending on your ping.

  • Automatically cancel past tweens of the same object if the “CanBeCancelled” setting is enabled.


Get it here!

Easy Server to Client Tween.rbxl (37.6 KB)

Roblox Model
(https://www.roblox.com/library/5044326016/Easy-Server-to-Client-Tween)


Edit: Fixed tick() syncing issue with quenty’s module

“So I have it, but how do I use it?”

(This is also located inside the module).

1: Create a server script, (or edit an existing one)
2: In the script, require the module

local EasyTween = require(rep:WaitForChild("EasyClientTween"))

3: Create the tween handler

local EasyTween = require(rep:WaitForChild("EasyClientTween"))
local tweenHandler = EasyTween.new(Cancellable, InStarterPlayer, ClientSync, DebugModeOverride) -- Can leave blank to have defaults, ex: local tweenHandler = EasyTween.new()

ex:  local tweenHandler = EasyTween.new(true,true,false,false)

4: Wherever you wanna tween (such as in a function, go about doing a regular tweenService:Create() but make tweenInfo in a table, ex: {time, easingstyle, easingdirection}

To make it tween for EVERYONE:

tweenHandler:TweenAllClients(objectToChange, TweenInfoTable, ValuesToTweenTable)
			-- Keep in mind that tweeninfo table is not TweenInfo.new() and is "{ Tweeninfo values here }"
		
		Ex: tweenHandler:TweenAllClients(objectToChange, {1.5, Enum.EasingStyle.Linear}, {Position = Vector3.new(0,5,0})

To make it tween for ONLY ONE person:

		local playerObject = game.Players.HiddenKaiser
		tweenHandler:TweenClient(playerObject, objectToChange, TweenInfoTable, ValuesToTweenTable)
		
		Ex: tweenHandler:TweenClient(playerObject, objectToChange, {1.5, Enum.EasingStyle.Quad}, {Position = Vector3.new(0,5,0})

If you have any ideas on modules or open source things you want tell me below!

Find the Github Source Here!

28 Likes

We already have this from SteadyOn

1 Like

Oh, my bad! I didn’t know it existed.

TweenService2 has a few unanswered bugs to it at the moment, not sure if it’s still being updated/worked on

2 Likes

I love it. Despite there being other posts, this was helpful to me.

2 Likes

I didn’t know that, never really used it tbh.

We also have this BoatTween module


@HiddenKaiser

Would you kindly create a link to Source code (preferably Github and/or Pastebin) for people who want to read the source but don’t have any access to a PC or maybe want to contribute to the source

1 Like

Here you are sir! First time doing this so apologies if it’s formatted weird.

1 Like

This looks very, very useful. The feature that syncs the tween based on the player’s ping is very unique. I’ll try this tomorrow and I think I’m going to enjoy it a lot, because TweenServiceV2 has been broken, and I’m too lazy to write my own module for this.

I really appreciate this resource, thank you! This is underappreciated.

1 Like

Could you explain how the syncing works, im trying to do this guns. And nevermores time sync module has to many dependencies and I don’t want all of that in my codebase.

I am interested in using this but does it have any events like TweenService does such as the Completed event? I think I would need this functionality to do destroy the tweened parts once they have completed.

thanks!

1 Like

My module does not support .Completed natively, but you could always just wait the tweens length which is probably a bit more reliable than something like .Event:Wait().

If you wanted to you could event wait the tweens length in a coroutine and fire a bindable event to get the same .Completed effect

1 Like

Is there any possible way to make this work with looped tweens?

1 Like

Sorry for the late response.

Just set the repeat count to -1 in the tweeninfo table instead of TweenInfo.new object, you pretty much have just the same amount of freedom as with regular tweens

Best of luck,
HiddenKaiser

Sorry i meant specifically with playing a tween then stopping it with :Stop(), so i don’t have to run a tween over it with the hope that it won’t quickly snap back when the next tween ends, unless it manually stops

1 Like

Oh theres a cancelable property in the settings when you create the tween handler, it’s the first property.

Edit:
I actually dont know if I ever made a stop function, next time i’m free i’ll add one to the module if it doesnt exist

If I have a moving brick that kills people, and I want it to look natural for all players so that
Player1 and Player2 see the part at the same place at the same time.
Because it is very important that it is synchronized. Does this do that, as it speeds up the tweens depending on their lag/latency?

Thanks, and by the way, amazing module - used it for a ton of projects! :slight_smile:

I think it is broken. Followed all the instructions and it does nothing. Here is the errors in output.
image

1 Like

Hey! Sorry to revive this topic 9 months later but I am trying to use your module. It all tweens to the Vector3 fine but does not move the part to the Vector3 on the server once finished. Is it suppose to do that?

Also I want the TweenPart to have a seat on it which will be connected through WeldConstraint. The seat does not move with the part how can I fix this?

Thank you :slight_smile:

Hey, I am using your module. It works fine and all in studio, but when I am in the actual roblox game, it is laggy. How can I fix this?

Hey. I’m re-making a game I submitted to Suit Up. My original game used Knit for network tweening and I was told that it was somewhat broken. I appreciate the time you’ve put into making a standalong library!

I’ve made a few bug fixes (EasyClientTween can’t always be in ReplicatedStorage). However, I didn’t look to notice that the source is on GitHub until after I finished making this post.

EasyClientTween.rbxm (8,8 KB)

1 Like