Pass works only on Roblox Studio

local plr = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
local id = 99789714

if mps:UserOwnsGamePassAsync(plr.UserId, id) then
	game.Lighting.color.Parent = game.Workspace
end

This game pass only works on Roblox Studio and not in the game. I appreciate any help.

Are there any errors in the game, like in the console? Also maybe try adding a wait(1) before the if statement.

Try converting this into a server script, then only run the script when the player has fully loaded.

Workspace.script:5: attempt to index nil with 'UserId'
1 Like

That is probably because it’s in a localscript.

1 Like

LocalPlayer needs to be in a localScript.

1 Like

Have you enabled access to api services?

1 Like

it’s already a localscript. I just changed the name to Script

1 Like

How is it running in the workspace then?

I just put it in workspace
(limitt)

local MPS = game:GetService("MarketPlaceService")
local ID = 99789714

game.Players.PlayerAdded:Connect(function(plr)

if MPS:UserOwnsGamePassAsync(plr.UserId, ID) then
game.Lighting.Color.Parent = game.Workspace

end
end)

Try this, put it as a serverscript in serverscriptservice

Unfortunately it doesn’t work, thanks anyway.

Where is your script located by the way?

I deleted the old localscript in workspace and made a new one in serverscriptservice, this time server script.

You have both a receipt script and the gamepass script right?
Also, localscripts can’t run anywhere like serverscripts

I don’t have a receipt script.

You can’t use LocalPlayer in a server script, so are you using the PlayerAdded function?

Okay, keep your original localscript for now.

1 Like

Ah, my bad, are there currently any errors in the console now, and maybe try print statements or breakpoints.