Start typing to search packages!
synctween
By @creacowo
Roblox
MirroredSyncTween
Created by @creaco - November 8th, 2024
Licensed under the GNU GPLv3 License
SyncTween is a tweening library designed to help server-to-client animations, with several features that other modules do not offer.
Links
- More information on TweenService found here.
- If you are unfamiliar with how replication works, please look at this DevForum post.
- This project was inspired by TweenService2, although not built onto it.
Advantages
-
Lower Server Load
By handling animations on the client side, SyncTween reduces the processing burden on the server. -
Smoother animations
Compared to the server, the client runs at a faster clock, meaning the animations will not be "choppy".
Key Features
-
Syncing Animations
SyncTween allows animations to be synchronized across all clients. Here's the definition of "synchronization":- Synchronization ensures that all clients see the animations in the same state at the same time.
- By default, all tweens will end at the same time, this means it compensates for server lag.
-
Custom Animations
You can define custom animations on the client side. Check out theCustommodule for examples. You can also use other Tweening modules combined with this module using a custom animation. -
Support for Streaming Enabled & Streaming Out
SyncTween works with Streaming Enabled and Streaming Out viaCollectionService. -
Selective Replication
Make animations visible to selected clients without replicating them to the server. For example, hide a door for User X but keep it visible for others. -
Selective Framerate Make certain animations run at a lower framerate to decrease the client load.
Current Limitations
- Custom animations cannot be paused.
How to Use SyncTween
To construct a SyncTween, use the following syntax:
SyncTween.new(
object: Instance, -- The object you want to animate.
tweenInfo: (TweenInfo | TweenArray | string)?, -- TweenInfo of the animation.
properties: { [string]: any }?, -- Properties you want to animate.
update: boolean?, -- Should the animation be updated to the server?
sync: (boolean | number)?, -- Synchronize all clients / set framerate.
additional: { [string]: any }?, -- Additional data for custom animations.
uuid: string? -- UUID of the animation (optional).
)
Parameter Notes:
tweenInfo: Accepts aTweenInfo, aTweenArray, or astring.- If a string is provided, it will be treated as a custom animation.
- A
TweenArraylooks like:{ Time = 1, EasingStyle = Enum.EasingStyle.Linear, EasingDirection = Enum.EasingDirection.InOut } - It’s recommended to use
TweenInfoto avoid confusion, the change was necessary for replication purposes.
Examples:
-
Animate a part's position:
SyncTween.new(workspace.Part, TweenInfo.new(1), { Position = Vector3.new(0, 10, 0) }):Play()This will animate the part to the position
(0, 10, 0)over 1 second. -
Animate a color for a specific player:
SyncTween.new(workspace.Part, nil, { Color = Color3.new(1, 0, 0) }, false):Play({Player1})This will turn the part red only for Player1.
-
Play a custom "Rainbow" animation at 10 FPS:
SyncTween.new(workspace.Part.Highlight, "Rainbow", true, 10):Play()
Global Methods
SyncTween.get(object: Instance, player: Player): { Sync }
Retrieve all animations currently playing on the specified object. On the client, this will return everything that is playing, on the server, it will return only Syncs that the player can view.
SyncTween Class Methods
-
Play(players: { Player }?)
Start the animation.
Ability to set the scope on who receives the animation. -
Pause(delta: number?)
Pause the animation.
(Does not apply to custom animations) -
Cancel()
Cancel the animation.
Summary
You can create a SyncTween (or "Sync") using SyncTween.new(). This class inherits the usual tween methods (:Play(), :Pause(), :Cancel()) while offering additional configuration options, such as:
tweenInfoupdatesyncuuid
This module is great for having animations replicate to various clients without the downside of server lag. This module also supports settings like framerate, which gives more freedom on how expensive animations should be.
The module is written in --!strict mode, and the Sync type is exported for use.
Package Details
Install command (Click to copy)
Version
1.0.8
License
GPL-3.0
Legal risk for closed-source games
Strong copyleft: shipping this in your game plausibly requires releasing your game's entire source under GPL-3.0. Not recommended for closed-source projects.
Automated license review — not legal advice.
