【问题标题】:leader stats not loading领导者统计未加载
【发布时间】:2022-10-31 03:23:03
【问题描述】:

我正在制作一个答题器游戏,我需要在 leaderstats 中设置一个乘数。在我添加数据存储并且它停止显示乘数之前,这一切都有效,但仍然显示点击。 这是我的代码:

local DSS = game:GetService("DataStoreService")

local ClicksStore = DSS:GetDataStore("ClicksStore")
local MultiStore = DSS:GetDataStore("MultiStore")

game.Players.PlayerAdded:Connect(function(player)
    
    local stats = Instance.new("Folder", player)
    stats.Name = "leaderstats"
    
    local clicks = Instance.new("IntValue", stats)
    clicks.Name = "Clicks"
    clicks.Value = ClicksStore:GetAsync(player.UserId.."--clicks") or 0
    
    local multi = Instance.new("IntValue", stats)
    multi.Name = "Multiplier"
    multi.Value = MultiStore:GetAsync(player.UserId.."--multi") or 1
    
    
    game.Players.PlayerRemoving:Connect(function()
        ClicksStore:SetAsync(clicks.Value, player.UserId.."--clicks")
        MultiStore:SetAsync(multi.Value, player.UserId.."--multi")
    end)
    
    while true do
        wait(300)
        ClicksStore:SetAsync(clicks.Value, player.UserId.."--clicks")
        MultiStore:SetAsync(multi.Value, player.UserId.."--multi")
    end
    
end)

这是截图 problem

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    在对SetAsync 的调用中,您的键和值倒退了。请参阅docs

        local clicksKey = player.UserId.."--clicks"
        local multiKey = player.UserId.."--multi"
    
        game.Players.PlayerRemoving:Connect(function()
            ClicksStore:SetAsync(clicksKey, clicks.Value)
            MultiStore:SetAsync(multiKey, multi.Value)
        end)
        
        while true do
            wait(300)
            ClicksStore:SetAsync(clicksKey, clicks.Value)
            MultiStore:SetAsync(multiKey, multi.Value)
        end
    

    【讨论】:

    • 好的,谢谢,但统计数据本身没有显示
    • 嗯,这很奇怪。对不起,我的回答没有帮助。
    • 很好,我想通了!但谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-10-11
    • 2021-11-08
    • 2017-06-07
    • 2012-08-01
    • 1970-01-01
    • 2017-09-15
    • 1970-01-01
    • 2010-11-28
    相关资源
    最近更新 更多