【发布时间】:2021-02-03 21:28:58
【问题描述】:
所以我一直在尝试将某个“文本”从 TextLabel 保存到 DataStore,数据保存成功,但是当尝试加载它时,它给了我一个“失败”,有什么帮助吗?
这是一个快速视频:https://www.youtube.com/watch?v=W-J6U8zmATk&feature=youtu.be
脚本:
local DataStoreService = game:GetService("DataStoreService")
local IDStorage = DataStoreService:GetDataStore("IDStorage3")
elseif Player.Team.Name == "Intelligence Agency" then
if Player:IsInGroup(7503826) or Player:GetRankInGroup(7465879) >= 251 then
Rank.User.Text = "[REDACTED]"
Rank.User.Back.Text = "[REDACTED]"
Rank.Rank.TextColor3 = Color3.new(0.827451, 0, 0)
game.ReplicatedStorage.NewID.OnServerEvent:Connect(function(player, playerToID, AssignedID)
if player:IsInGroup(7465879) then
local success, err = pcall(function()
IDStorage:SetAsync(playerToID, AssignedID)
end)
if success then
print("Data Assigned") -- Data Works and Saves
else
warn("Failed to Save")
end
end
end)
local ID = IDStorage:GetAsync(Player)
if ID then
print(ID)
else
warn("Failed") -- Always Returns me this.
Rank.Rank.Text = "0"
end
Rank.User.Text = "[REDACTED]"
Rank.User.Back.Text = "[REDACTED]"
end
【问题讨论】:
-
当您调用
IDStorage:SetAsync(key, value)时,您使用什么参数作为密钥? -
键是用户名,值是ID(playerToID,AssignedID)。如果我正确理解了问题,我有一个 GUI 可以触发服务器并发送目标(playerToID)和一个 ID(例如:1234567890)来分配给用户(AssignedID)(两者都来自文本框)。
@Kylaaa
标签: roblox