What does "wrap in a pcall" mean? evayoushouldreallyfixthetitleexploitthx
Asked by
5 years ago Edited 5 years ago
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.
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local experienceStore = DataStoreService:GetDataStore( "PlayerExperience" ) |
04 | ** local success, err = pcall **( function () |
05 | experienceStore:SetAsync( "Player_1234" , 50 ) |
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;
1 | InventoryFunction.OnServerInvoke = |
2 | function (playerID,Intent, number) |
3 | if Intent = = "read" then |
4 | return Inventory:GetAsync(playerID) |
5 | else if Intent = = "increment" then |
6 | Inventory:IncrementAsync(playerID, number) |
That works, i know it, but how can i add a pcall to catch data-store problems?