Skip to content

!! WORK IN PROGRESS !!

Migrating to 2.0

Tutorial on how to migrate to 2.0

Lua 5.2 -> Luau

This is the biggest compatibility breaking change for 2.0. The transition from Lua 5.2 (Moonsharp) to Luau. One of the big change being the now non-available goto statements. Which you'll have to switch to continue statement instead.

Unique Names

Each instances should now have it's own unique name, this is by design and allows for faster lookups. If you want to identify objects with the same instance type, use tags.

Capitalization

Functions including _update and _fixedUpdate has been capitalized. Use _Update and _FixedUpdate

Fields like Vector3.new Vector3.x has also been capitalized to Vector3.New, Vector3.X

Enum Table

Enums should be accessed from the global Enums table. for example:

Enums.PartMaterial.Brick

Tweening

Tweening has been revamped in 2.0. You should create a tween object first, then tween it from there. Example:

local part: Part = script.Parent
local origin = part.Position
local tw = Tween:NewTween()

print("Tween Start!")

tw:TweenVector3(origin, origin + Vector3.New(0, 10, 0), 10, function(val)
    part.Position = val
end)

tw.Finished:Wait()

print("Tween Finished!")

Particles

Particles has been revamped in 2.0.

Datastore retrieving

Datastore now no longer requires waiting for it to load first.

local ds = Datastore:GetDatastore("datastore1")
ds:SetAsync("coins", 11)
local coins: number = ds:GetAsync("coins")
print(coins)

You may notice that these function now require Async suffix, which brings us to:

Async functions

Some function will now be required to be async in non compatibility mode. These include but not limited to: Http requests, Datastore data retrieving, Insert via InsertService etc.

Example HTTP Request made with 2.0:

local success, res = pcall(function()  
    return Http:GetAsync("http://example.com/")
end)
print(success, res)

To run multiple tasks simultaneously, use spawn

spawn(function() 
    local success, res = pcall(function()  
        return Http:GetAsync("https://example.com")
    end)
    print(success, res)
end)

local ds = Datastore:GetDatastore("datastore1")
ds:SetAsync("coins", 11)
local coins: number = ds:GetAsync("coins")
print(coins)