Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why This GamePass Script Not Running after added pcall()?

After I added the pcall() modifications, it stopped working, and even before that it didn't work 100% of the time. Any errors you can spot?

function isAuthenticatedforBlowgun(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 483225340)
end

function isAuthenticatedforSlots(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 483221291)
end
 
while wait() do
	for _,plr in ipairs(game.Players:GetPlayers()) do
		local success, message = pcall(isAuthenticatedforBlowgun)
	    if success then
	        game.ReplicatedStorage.GamepassEvent:FireClient(plr, "Blowgun")
	    end
	end
	for _,plr in ipairs(game.Players:GetPlayers()) do
		local success, message = pcall(isAuthenticatedforSlots)
		if success then
			game.ReplicatedStorage.GamepassEvent:FireClient(plr,"4Slots")
		elseif not success then
			print('slots gamepass not working..')
		end
	end
end

1 answer

✓ Accepted answer

isAuthenticatedforBlowgun(player) requires a player parameter, but you don't provide that parameter when you simply do pcall(isAuthenticatedforBlowgun).

Do this: pcall(function() isAuthenticatedforBlowgun(plr) end)

You probably don't need to use pcall anyway but whatever.

This discussion is preserved as it was. New answers, comments, and votes are closed.