【发布时间】:2021-06-30 21:27:06
【问题描述】:
关于 Roblox 工作室的问题,或者更确切地说,关于 dataStore 的问题。如果在输出 data:GetCurrentPage() 时通过 pointsStore:SetAsync ("Mars", 19) 直接将值保存在脚本中 - 此值将被输出,但如果您通过函数执行此操作,则会保存该值,但不会数据时不出现:GetCurrentPage()。如何保存用户数据?
将值直接保存在脚本中:
PlayerPoints:SetAsync("Mars", 19)
local success, err = pcall(function()
local Data = PlayerPoints:GetSortedAsync(false, 5)
local WinsPage = Data:GetCurrentPage()
print(WinsPage)
end)
将值直接保存在函数中:
local function givePointsPlayer(player, points)
local pointsOld = pointsStore:GetAsync(player.Name.."&"..tostring(player.UserId).."&"..tostring(os.date("*t").month))
if (pointsOld == nil) then
pointsOld = 0
end
print(pointsOld)
local success, err = pcall(function()
pointsStore:SetAsync(
player.Name.."&"..tostring(player.UserId).."&"..tostring(os.date("*t").month),
pointsOld + points
)
end)
end
EventEditPointsPlayer.OnServerEvent:Connect( function(player, points)
givePointsPlayer(player, points)
end)
回答: answer
如何保存用户数据以便通过 :GetCurrentPage() 输出??
【问题讨论】:
标签: lua roblox datastore leaderboard