MarketplaceService:UserOwnsGamePassAsync | Problem

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I would like it so when a person owns a gamepass, it gives them a keycard when they spawn and I don’t know what’s wrong with it.

  2. What is the issue? It doesn’t trigger that the gamepass is in someone’s inventory.

  3. What solutions have you tried so far? Yes. I have tried removing the CharacterAdded and much more.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Server:

local id = 10111638
 

game.Players.PlayerAdded:connect(function(player)
 player.CharacterAdded:Connect(function()
	 if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, id) then
			game.Lighting["[SCP] Card-L3"]:Clone().Parent = player:WaitForChild("Backpack")
 end
end)
end)

UserId is with capital U, try that, I think the problem is just a typo.
And connect is deprecated, you should use Connect, with capital C

1 Like

Try adding prints to debug the code and are there any errors in the output?
Try changing connect with capital C since connect is deprecated as well as userId with capital U.

I love the python indenting

I agree. The userId should be replaced with UserId, but connect does not need to be changed to Connect. It works fine for me with connect, aswell as Connect.

True, but connect is deprecated, it is better to use Connect, which is not deprecated.
I said should, they both work as you said :slightly_smiling_face:

I know this isn’t that relevant but how would I check the environment the player is running in, whether they are in Studio or in a Game Server?

Use RunService

2 Likes

Use run service, it has a method that checks if it’s in the studio.

if game:GetService("RunService"):IsStudio() then
     --Code
end

But I think you should mark this topic as solved if it worked for you, because it’s another question now, and we all answered to the first question.

1 Like

Just a question, why did you put the keycard in “Lighting”? And not in a Storage like ReplicatedStorage or ServerStorage or ReplicatedFirst?

I have a team of builders and tool makers that put tools in different places. We should organise it a bit more.