Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why bind to close function in my datastore script gives an error?

Asked by 2 years ago

So i improved my datastore script to make it work but output said: ServerScriptService.Events.ComData:22: attempt to call a nil value Script:

local ds = game:GetService("DataStoreService")
    local bool = ds:GetDataStore("ComSaving")
game.Players.PlayerAdded:Connect(function(plr)
    print("Player Joining...")
            local boolValue = plr:WaitForChild("PlayerGui"):WaitForChild("QuestGui").CompletedData
            boolValue.Value = bool:GetAsync(plr.UserId) or false
        end)

game.Players.PlayerRemoving:Connect(function(plr)
    print("Player Leaving...")
    --local success, err = pcall(function()
        bool:SetAsync(plr.UserId, plr.PlayerGui.QuestGui.CompletedData.Value)
        end)
--end)

game:BindToClose(function()
    print("Bind is loading...")
    for i, v in pairs(game.Players:GetPlayers()) do
        local data = {
            ["QCA"] = v.PlayerGui.QuestGui.CompletedData.Value,
        }
        data:GetAsync(v.UserId, data)
    end
end)
0
Ps: i changed get to set a sync in 22 line, still error SashaPro336 47 — 2y

Answer this question