Im trying to mess with data stores, and as im referencing the API site, they said to "wrap your function call with a pcall." I understand the purpose, not the implementation.
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
**local success, err = pcall**(function()
experienceStore:SetAsync("Player_1234", 50)
end)
if success then
print("Success!")
end
See, WHAT WOULD BE the bold part is what i dont understad. they make a variable, then another that equals pcall? wtf is pcall? why cant i find any documentation on how to use it? how is it connected to the function? HOW IS IT EVEN ALLOWED TO WEDGE ITSELF BETWEEN THE FUNCTION NAME AND THE FUNCTION??
I would just copy paste the code and be done with it, but im trying to implement it into a server-invoke call. So it looks dicey as is;
InventoryFunction.OnServerInvoke=
function (playerID,Intent, number)
if Intent == "read" then
return Inventory:GetAsync(playerID)
else if Intent == "increment" then
Inventory:IncrementAsync(playerID, number)
end
end
end
That works, i know it, but how can i add a pcall to catch data-store problems?

1 comment
Ill accept the answer. but now im having troubles trying to return a value from a function, within a function