Gamepass Script Not Working

My script is not working for my gamepass.

	local MPS = game:GetService("MarketplaceService")
	local plr = script.Parent.Parent.Parent.Parent.Parent
	local Id = 14781556
	if MPS:PlayerOwnsAsset(plr, Id) == true then
		plr.Stats.Weapon.Value = game.ReplicatedStorage.Weapons["Fiery Souls"]
	else
		MPS:PromptGamePassPurchase(plr, Id)
	end
end)

Try using UserOwnsGamePassAsync:

local MPS = game:GetService("MarketplaceService")
local plr = script.Parent.Parent.Parent.Parent.Parent
local Id = 14781556
if MPS:UserOwnsGamePassAsync(plr.UserId, Id) then
plr.Stats.Weapon.Value = game.ReplicatedStorage.Weapons["Fiery Souls"]
else
MPS:PromptGamePassPurchase(plr, Id)
end

Also, the way you’re accessing the player (script.Parent.Parent.Parent.Parent.Parent) is questionable, that might be causing an issue if it’s not correctly referencing a player.

1 Like

Ok. I don’t think the player reference is a problem though. I will try :UserOwnsGamePassAsync. Thanks man!

Edit: Yay! It works. Thanks @TopBagon

1 Like