How bad is this way to manage gamepasses?

Hi! what do you think about this?


for i, Gamepass in pairs(gpFolder:GetChildren()) do
	local gamepass ="BoolValue")	
	gamepass.Name = Gamepass.Name
	gamepass.Value = false
	local hasPass = false
	local s,e = pcall(function()
		hasPass = MPS:UserOwnsGamePassAsync(player.UserId,gamepasses[Gamepass.Name])

	if	hasPass == true then gamepass.Value = true end
	gamepass.Parent = GamepassesFolder
	if not s then print(e) end

Does this script work in a way you don’t want it to?

1 Like

Apparently it works fine, buy I read a lot about not using loops, not using wait(), so I ask

loops are fine. Its when you are looping infinitly without a stopping point that it becomes an issue. As your wait() question, I dont see any use for it here except slowing down your gamepass checking which would just make the gamepasses longer to load for no reason.

1 Like

so it will not fail or something if that FOR checks the gamepasses at full speed?

The way ROBLOX actually handles Async functions is by yielding the thread till a response has been returned, so that wait isn’t required.

1 Like