#Pcall Question
1 messages · Page 1 of 1 (latest)
local function someError()
error("Im not working")
end
local function noError()
local something = 2
return something
end
local success, result = pcall(someError)
local success, result = pcall(noError)
so in one function theres an error, success is aboolean (true or false) and result is either the error message or the actual return from the function.
If you would print result in the first function it would print the error ("Im not working" and in the other function it would print the variable something.
@stoic nimbus
Pcalls should be used for saving data and loading it. And you can also use them for unstable code.
pcall is used for protecting the call obviously
ok but other than that
when people do local success, result = pcall(function()
success would be a boolean
i mean
result
forgot which one
no its the other way around its for unstable code and it CAN be used for saving data 😭
mb im pretty new to it aswell! Thank you for correcting me
its just the way i have been using them until now
but which other secure way could you use to save data without a pcall?
profileservice surely also uses pcall in their source code..
not when you have to like actually make the script
ye
6 pcalls
but what would be a way to save data without pcalls then
💔
you don't necessarily need pcalls they just make it "safer"
ig.