Skip to content

Module for animating Roblox instances from the server on the client.

License

Notifications You must be signed in to change notification settings

IITPP-Roblox/LocalTween

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalTween

LocalTween is a module developed for the Innovation Inc Thermal Power Plant on Roblox to coordinate property tweens (transitions to new states) from the server while still having the smoothness of being run on the client. In addition, the module supports tweening models.

The module is fairly simple in design and does not support a bunch of features, including:

  • Pausing or canceling tweens.
  • TweenInfo with non-default repeatCount, reverses, or delayTime.
  • Guaranteeing order and overriding of tweens. Currently, this can be unpredictable.
  • Throttling model tweens depending on conditions like distance.

Setup

Project

This project uses Rojo for the project structure. Two project files in included in the repository.

  • default.project.json - Structure for just the module. Intended for use with rojo build and to be included in Rojo project structures as a dependency.
  • demo.project.json - Full Roblox place that can be synced into Roblox studio and ran with demo models.

Game

LocalTween is not self-contained and requires additional setup to use. On the server, the module only needs to be required. On the client, it needs to be required and SetUp() needs to be invoked. LocalTweenSetup.client.lua is an example if LocalTween is directly under ReplicatedStorage.

require(game:GetService("ReplicatedStorage"):WaitForChild("LocalTween")):SetUp()

The specific location of LocalTween does not matter as long as SetUp is called on the client.

API

Base API

LocalTween:Play(Target: Instance, Info: TweenInfo | number, Properties: table): nil

Creates a plays a tween on the client. The Info parameter can be a TweenInfo or a number similar to TweenInfo.new(Duration). Compared to the TweenService:

local TweenService = game:GetService("TweenService")
TweenService:Create(SomePart, TweenInfo.new(5), {
    Transparency = 1,
}):Play()

and LocalTween:

local LocalTween = require(game:GetService("ReplicatedStorage"):WaitForChild("LocalTween"))

--Option 1
LocalTween:Play(SomePart, TweenInfo.new(5), {
    Transparency = 1,
})

--Option 2 (no TweenInfo.new)
LocalTween:Play(SomePart, 5, {
    Transparency = 1,
})

For models, use the CFrame property or use the TweenModel helper function.

local LocalTween = require(game:GetService("ReplicatedStorage"):WaitForChild("LocalTween"))
LocalTween:Play(SomeModel, TweenInfo.new(5), {
    CFrame = CFrame.new(0, 5, 0),
})

LocalTween:SetUp(): nil

Sets up the LocalTween replication on the client. Calling it more than once is unsupported and can lead to unexpected behavior.

Helper API

LocalTween:TweenModel(Model: Model, Info: TweenInfo | number, Target: CFrame | BasePart): nil

Tweens a model to a given CFrame or part. If a part is specified, the CFrame will be Part.CFrame.

LocalTween:TweenMotorSpeed(Motor6D: Motor6D, Speed: number, Info: TweenInfo | number): nil

Tweens the DesiredSpeed of a Motor6D to a given speed. This is included due to how many Motor6Ds are used in the Innovation Inc Thermal Power Plant.

License

This project is available under the terms of the MIT License. See LICENSE for details.

About

Module for animating Roblox instances from the server on the client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages