migration guide

This commit is contained in:
maji
2026-02-02 01:40:25 +07:00
parent 29f7d06b2f
commit 2ed84471d6
2 changed files with 87 additions and 0 deletions

7
docs/tutorials/index.md Normal file
View File

@@ -0,0 +1,7 @@
---
title: Tutorials
weight: 3
empty: true
---
# Tutorials

View File

@@ -0,0 +1,80 @@
---
title: Migrating to 2.0
description: 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:
```lua
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.
```lua
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:
```lua
local success, res = pcall(function()
return Http:GetAsync("http://example.com/")
end)
print(success, res)
```
To run multiple tasks simultaneously, use `spawn`
```lua
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)
```