Roblox Script Using TweenService for Animation

Posted on April 26, 2020

This is a hello-world for Tween, aka Animation. Given a Part in the workplace named Little, this script will randomize its position animating the change:

local TweenService = game:GetService("TweenService")

while true do
    wait(5)
    
    local goal = {Position = Vector3.new(math.random(-20,20), 10, math.random(-20,20))}
    
    local twinfo = TweenInfo.new(3)
    local tw = TweenService:Create(workspace.Little, twinfo, goal)
    tw:Play()
    
end