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

Making sure data store goes through?

Asked by
NiKxzsu 13
5 years ago

I want to make sure the pcall thing goes through. Is this a good way to make sure that it always goes through or is there a better way to do this? (Without a loop?)

game.Players.PlayerAdded:Connect(function(p)
    local label = p:WaitForChild("PlayerGui"):WaitForChild("currency"):WaitForChild("Frame"):WaitForChild("TextLabel")
    repeat
        wait(1)
        local s,e = pcall(function()
            local store = gold:GetAsync("player_"..p.userId)
            if store then
                label.Text = store
            else
                gold:SetAsync("player_"..p.userId,0)
                label.Text = 0
            end
        end)
    until s == true
end)
0
btw label = p:WaitForChild("PlayerGui"):WaitForChild("currency"):WaitForChild("Frame"):WaitForChild("TextLabel") NiKxzsu 13 — 5y

Answer this question