Need help with Pcall()

SOlUTION ((This logic makes no sense - #4 by DataSigh))

  1. What do you want to achieve? Keep it simple and clear!

I want to know what SUCCESS will equal to (false or true) if the GETASYNC line of code never finds the playerProductKey inside the data

Some other unrelated questions: Imagine a function outside the ((elseif not success)) if the error(“…”) inside that elseif statement runs will it exit the function.

Again image a function outside of the ((if success and purchased)) if the line of code inside runs will it exit the function and stop running the code after it

success, errorMessage = pcall(function()
		purchased = purchaseHistoryStore:GetAsync(playerProductKey)
	end)
	if success and purchased then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not success then
		error("Data store error:" .. errorMessage)
	end
2 Likes

success returns a boolean, so youre using it right here

1 Like

I want to know specifically false or true

1 Like

itd be false if youre trying to hit the elseif loop. replacing the elseif with an else loop works as well since all youre looking for is a true success var

I also need help on the second and third question

itll exit the function yes since there isnt anymore code to run it just wont return anything, if success and purchased do have a value then its going to return that enum and will exit the function, not running the elseif loop argument

imagine that there is more code to run inside the function if the error() triggers will the rest of the code run

yes since there is no return or break

You were wrong about if about if purchased equals false then success will also equal false; apparently what purchased equals to has no effect on success which makes much more sense.

calling error() stops the code

2 Likes

thanks gang didnt know i thought it was likea warn() sorta thing

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.