Can't set a value through UserOwnsGamepassAsync()

So I’m not sure why, because the print lines print("hi") and print("success!") show up, but it doesn’t want to set the value.

Script:

local MarketPlace = game:GetService("MarketplaceService")
local ID = 6645699

game.Players.PlayerAdded:Connect(function(player)
	local hasPass = false
	local success, message = pcall(function()
		hasPass = MarketPlace:UserOwnsGamePassAsync(player.UserId, ID)
	end)
	if not success then
		error("Error! "..tostring(message))
	end
	if hasPass == true then
		print("hi")
		player:WaitForChild("Gamepasses").OwnsPowerPack.Value = true
		print("success!")
	else
		print(player.Name.." doesn't own Power Pack.")
	end
end)

Thanks! :slight_smile:

Does the value set ever print out a warning regarding an infinite yield after waiting some seconds? What is the type of value you have to work with? Is this being ran from a LocalScript or a server script? Sure it’s not being set and that you’re overlooking this a bit?

No. Boolean is the type. Server script. I checked the values in the explorer.

Nevermind, I just had to copy the function and modify it a bit in a LocalScript