local Gamepasses = { ["3025362"] = game.ServerStorage.Items.Passes["Boombox"], -- ["3025376"] = game.ServerStorage.Items.Passes["Fists"], ["3025369"] = game.ServerStorage.Items.Passes["HandlessSegway"], ["3025380"] = game.ServerStorage.Items.Passes["P226"], ["3025365"] = game.ServerStorage.Items.Passes["ProtestSign"], -- ["1233826172"] = game.ServerStorage.Items.Passes["Pump"], } function CheckPasses(Player) print('checking') print(Player) local Market = game:GetService("MarketplaceService") for PassID,PassTool in pairs (Gamepasses) do print(Market:PlayerOwnsAsset(Player, PassID)) if Market:PlayerOwnsAsset(Player, PassID) then PassTool:Clone().Parent = Player.Backpack end end end game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function() CheckPasses(Player) end) end)
I own the gamepass but its returning false when I try and print it to see if it is returning true or false for some reason anyone know why?
An update was made to game passes in April of 2018. This update made game passes not be assets anymore. You can use the new method :UserOwnsGamePassAsync()
. Note that instead of the player, it is their UserId.
local Gamepasses = { [3025362] = game.ServerStorage.Items.Passes["Boombox"], -- [3025376] = game.ServerStorage.Items.Passes["Fists"], [3025369] = game.ServerStorage.Items.Passes["HandlessSegway"], [3025380] = game.ServerStorage.Items.Passes["P226"], [3025365] = game.ServerStorage.Items.Passes["ProtestSign"], -- [1233826172] = game.ServerStorage.Items.Passes["Pump"] } local Market = game:GetService("MarketplaceService") local function CheckPasses(Player) print("checking") print(Player) for PassID, PassTool in pairs (Gamepasses) do if Market:UserOwnsGamePassAsync(Player.UserId, PassID) then PassTool:Clone().Parent = Player.Backpack end end end game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function() CheckPasses(Player) end) end)
local Gamepasses = { ["3025362"] = game.ServerStorage.Items.Passes["Boombox"], ["3025376"] = game.ServerStorage.Items.Passes["Fists"], ["3025369"] = game.ServerStorage.Items.Passes["HandlessSegway"], ["3025380"] = game.ServerStorage.Items.Passes["P226"], ["3025365"] = game.ServerStorage.Items.Passes["ProtestSign"], ["1233826172"] = game.ServerStorage.Items.Passes["Pump"], } function CheckPasses(Player) print('checking') print(Player) local Market = game:GetService("MarketplaceService") for PassID,PassTool in pairs (Gamepasses) do print(Market:UserOwnsGamePassAsync(Player, PassID))--it is now UserOwnsGamePassAsync (they changed it you are trying to sell a model/place and give them stuff for it) since some time they changed it (I have no idea when I was off ROBLOX Studio and stuff for like 4 months of 2018. if Market:UserOwnsGamePassAsync(Player, PassID) then --same thing here PassTool:Clone().Parent = Player.Backpack end end end game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function() CheckPasses(Player) end) end)