เรียนรู้
Engine Class
DataStore
ไม่สามารถสร้าง
ไม่ซ้ำ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
ListKeysAsync(prefix: string,pageSize: number,cursor: string,excludeDeleted: boolean):DataStoreKeyPages
ListVersionsAsync(key: string,sortDirection: Enum.SortDirection,minDate: number,maxDate: number,pageSize: number):DataStoreVersionPages
RemoveVersionAsync(key: string,version: string):()
เลิกใช้แล้ว
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GetVersionAsync
ผลตอบแทน
ความสามารถ: DataStore
DataStore:GetVersionAsync(
key:string, version:string
พารามิเตอร์
key:string
version:string
ส่งค่ากลับ

GetVersionAtTimeAsync
ผลตอบแทน
ความสามารถ: DataStore
DataStore:GetVersionAtTimeAsync(
key:string, timestamp:number
พารามิเตอร์
key:string
timestamp:number
ส่งค่ากลับ
ตัวอย่างโค้ด
การเรียกข้อมูลเวอร์ชัน DataStore ตามเวลา
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("DataStore")
local key = "key-123"
function setData(data)
local success, result = pcall(function()
dataStore:SetAsync(key, data)
end)
if not success then
warn(result)
end
end
function getVersionAtTime(timestamp)
local success, result, keyInfo = pcall(function()
return dataStore:GetVersionAtTimeAsync(key, timestamp.UnixTimestampMillis)
end)
if success then
if result == nil then
print("ไม่พบเวอร์ชันที่เวลานี้")
else
print(result, keyInfo.Version)
end
else
warn(result)
end
end
-- ทำงานเมื่อ 2024/12/02 6:00 UTC
setData("เวอร์ชัน 1")
-- ทำงานเมื่อ 2024/12/02 9:00 UTC
setData("เวอร์ชัน 2")
-- พิมพ์ "ไม่พบเวอร์ชันที่เวลานี้"
local time1 = DateTime.fromUniversalTime(2024, 12, 02, 05, 00)
getVersionAtTime(time1)
-- พิมพ์ "เวอร์ชัน 1 <version>"
local time2 = DateTime.fromUniversalTime(2024, 12, 02, 07, 00)
getVersionAtTime(time2)
-- พิมพ์ "เวอร์ชัน 2 <version>"
local time3 = DateTime.fromUniversalTime(2024, 12, 02, 10, 00)
getVersionAtTime(time3)

ListKeysAsync
ผลตอบแทน
ความสามารถ: DataStore
DataStore:ListKeysAsync(
prefix:string, pageSize:number, cursor:string, excludeDeleted:boolean
พารามิเตอร์
prefix:string
pageSize:number
ค่าเริ่มต้น: 0
cursor:string
excludeDeleted:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ

ListVersionsAsync
ผลตอบแทน
ความสามารถ: DataStore
DataStore:ListVersionsAsync(
key:string, sortDirection:Enum.SortDirection, minDate:number, maxDate:number, pageSize:number
พารามิเตอร์
key:string
sortDirection:Enum.SortDirection
ค่าเริ่มต้น: "Ascending"
minDate:number
ค่าเริ่มต้น: 0
maxDate:number
ค่าเริ่มต้น: 0
pageSize:number
ค่าเริ่มต้น: 0
ส่งค่ากลับ
ตัวอย่างโค้ด
ดึงข้อมูลเวอร์ชัน DataStore ด้วยตัวกรองวันที่
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local time = DateTime.fromUniversalTime(2020, 10, 09, 01, 42)
local listSuccess, pages = pcall(function()
return experienceStore:ListVersionsAsync("User_1234", nil, time.UnixTimestampMillis)
end)
if listSuccess then
local items = pages:GetCurrentPage()
for key, info in pairs(items) do
print("คีย์:", key, "; เวอร์ชัน:", info.Version, "; สร้างเมื่อ:", info.CreatedTime, "; ลบ:", info.IsDeleted)
end
end

RemoveVersionAsync
เลิกใช้แล้ว

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ