Skip to main content

Animation

Animation library for animating instances.

Install with wally by adding the following to your wally.toml:

Animation = "dig1t/animation@1.0.8"

Types

AnimationConfig

interface AnimationConfig {
sourceInstance--

The instance to animate

start{[string]any}?--

Starting properties (this will overwrite the current properties)

goal{[string]any}--

Properties to animate to

tweenInfoTweenInfo?--

TweenInfo for the animation

frameCallback() → ()?--

Callback that runs on each RunService step

stopped(Enum.PlaybackState) → ()?--

Callback for when the animation is stopped

awaitboolean?--

Wait for the animation to complete

loopnumber?--

Times to loop the animation

reverseboolean?--

Reverse the animation after it's done

delaynumber?--

Delay before starting the animation

}

Animation configuration.

Warning: setting loop, reverse, or delay will overwrite tweenInfo if it's defined.

Properties

defaultConfig

Animation.defaultConfig: AnimationConfig

The default animation configuration.

Example:

Animation.setDefaultConfig({
	tweenInfo = TweenInfo.new(1),
	start = {
		Transparency = 1
	},
	goal = {
		Transparency = 0
	}
})

Animation.weldModel(model)

-- Animate the model
Animation.animate({
	source = model.PrimaryPart,
})

Functions

weldModel

Animation.weldModel(
modelModel--

The model to prepare

) → ()

Welds all descendant parts to the primary part.

This requires the model to have a PrimaryPart set.

setDefaultConfig

Animation.setDefaultConfig(
configAnimationConfig--

The default animation configuration

) → ()

Sets the default animation configuration.

promise

Animation.promise(
configAnimationConfig--

The animation configuration

) → Promise.Promise

Animates an instance and returns a promise.

play

Animation.play(
configAnimationConfig--

The animation configuration

) → Tween--

The tween instance

Animates an instance.

promiseAll

Animation.promiseAll(
instances{Instance},--

The instances to animate

configAnimationConfig--

The animation configuration

) → Promise.Promise

Animates multiple instances and returns a promise.

new

Animation.new(
configAnimationConfig--

The animation configuration

) → Tween--

The tween instance

Constructs a tween

Show raw api
{
    "functions": [
        {
            "name": "weldModel",
            "desc": "Welds all descendant parts to the primary part.\n\nThis requires the model to have a PrimaryPart set.",
            "params": [
                {
                    "name": "model",
                    "desc": "The model to prepare",
                    "lua_type": "Model"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 88,
                "path": "src/Animation/init.luau"
            }
        },
        {
            "name": "setDefaultConfig",
            "desc": "Sets the default animation configuration.",
            "params": [
                {
                    "name": "config",
                    "desc": "The default animation configuration",
                    "lua_type": "AnimationConfig"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/Animation/init.luau"
            }
        },
        {
            "name": "promise",
            "desc": "Animates an instance and returns a promise.",
            "params": [
                {
                    "name": "config",
                    "desc": "The animation configuration",
                    "lua_type": "AnimationConfig"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise.Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 123,
                "path": "src/Animation/init.luau"
            }
        },
        {
            "name": "play",
            "desc": "Animates an instance.",
            "params": [
                {
                    "name": "config",
                    "desc": "The animation configuration",
                    "lua_type": "AnimationConfig"
                }
            ],
            "returns": [
                {
                    "desc": "The tween instance",
                    "lua_type": "Tween"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 145,
                "path": "src/Animation/init.luau"
            }
        },
        {
            "name": "promiseAll",
            "desc": "Animates multiple instances and returns a promise.",
            "params": [
                {
                    "name": "instances",
                    "desc": "The instances to animate",
                    "lua_type": "{ Instance }"
                },
                {
                    "name": "config",
                    "desc": "The animation configuration",
                    "lua_type": "AnimationConfig"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise.Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 162,
                "path": "src/Animation/init.luau"
            }
        },
        {
            "name": "new",
            "desc": "Constructs a tween",
            "params": [
                {
                    "name": "config",
                    "desc": "The animation configuration",
                    "lua_type": "AnimationConfig"
                }
            ],
            "returns": [
                {
                    "desc": "The tween instance",
                    "lua_type": "Tween"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 184,
                "path": "src/Animation/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "defaultConfig",
            "desc": "The default animation configuration.\n\nExample:\n```lua\nAnimation.setDefaultConfig({\n\ttweenInfo = TweenInfo.new(1),\n\tstart = {\n\t\tTransparency = 1\n\t},\n\tgoal = {\n\t\tTransparency = 0\n\t}\n})\n\nAnimation.weldModel(model)\n\n-- Animate the model\nAnimation.animate({\n\tsource = model.PrimaryPart,\n})\n```",
            "lua_type": "AnimationConfig",
            "source": {
                "line": 48,
                "path": "src/Animation/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "AnimationConfig",
            "desc": "Animation configuration.\n\nWarning: setting loop, reverse, or delay will overwrite tweenInfo if it's defined.",
            "fields": [
                {
                    "name": "source",
                    "lua_type": "Instance",
                    "desc": "The instance to animate"
                },
                {
                    "name": "start",
                    "lua_type": "{ [string]: any }?",
                    "desc": "Starting properties (this will overwrite the current properties)"
                },
                {
                    "name": "goal",
                    "lua_type": "{ [string]: any }",
                    "desc": "Properties to animate to"
                },
                {
                    "name": "tweenInfo",
                    "lua_type": "TweenInfo?",
                    "desc": "TweenInfo for the animation"
                },
                {
                    "name": "frameCallback",
                    "lua_type": "() -> ()?",
                    "desc": "Callback that runs on each RunService step"
                },
                {
                    "name": "stopped",
                    "lua_type": "(Enum.PlaybackState) -> ()?",
                    "desc": "Callback for when the animation is stopped"
                },
                {
                    "name": "await",
                    "lua_type": "boolean?",
                    "desc": "Wait for the animation to complete"
                },
                {
                    "name": "loop",
                    "lua_type": "number?",
                    "desc": "Times to loop the animation"
                },
                {
                    "name": "reverse",
                    "lua_type": "boolean?",
                    "desc": "Reverse the animation after it's done"
                },
                {
                    "name": "delay",
                    "lua_type": "number?",
                    "desc": "Delay before starting the animation"
                }
            ],
            "source": {
                "line": 68,
                "path": "src/Animation/init.luau"
            }
        }
    ],
    "name": "Animation",
    "desc": "Animation library for animating instances.\n\nInstall with wally by adding the following to your `wally.toml`:\n```toml\nAnimation = \"dig1t/animation@1.0.8\"\n```",
    "source": {
        "line": 20,
        "path": "src/Animation/init.luau"
    }
}