1.8 KiB
title, description
| title | description |
|---|---|
| Migrating to 2.0 | Guide on how you can migrate your place to 2.0 |
!! 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.
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)