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

How do I access a Variable inside the Pcall function Do I redefine or is there a better way?

Asked by 5 years ago
Edited 5 years ago
local S,E = pcall(function()

    local GotAsync = DataStore:GetAsync(plr.UserId)

    return GotAsync
end)


local GotAsync = DataStore:GetAsync(plr.UserId) --ReDefine it?


How would I define it here outside the function do I have to redefine it or is there some other method?

But I think if I redefined it Problems would arise like the GetAsync in Pcall Might be succesful but In GotAsync outisde of the function it might fail

0
I believe it is already defined in your code... you could do local plr on line 1 greatneil80 2647 — 5y
0
Whatever you return in the pcall function will be the E variable ForeverBrown 356 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
local GotAsync
local S,E = pcall(function()
    GotAsync = DataStore:GetAsync(plr.UserId)
end)
Ad

Answer this question