First and foremost, we should learn what pcall’s syntax really looks like:
1 | pcall (f : function , ...args : any) |
Basically, you pass your desired function in as argument 1 and any arguments you want to pass to that function that’s going to be pcall’d as argument 2, 3, 4 etc - Pcall doesn’t mind how many arguments you want to pass to it!
Roblox DataStoreService, wonderful thing it is saving data between playing sessions.
There are some issues though when trying to Set/Get data which could even lead to data loss - no one wants to join a game and not have their data saved or retrieved.
This is where pcalls come in, you can use them to set/get data and check if it really did.
Commonly people do:
1 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "MyData" ) |
3 | local success, response = pcall ( function () |
4 | data = DataStore:GetAsync( "key" ) |
That's the basics about pcall() so hope you understand it!