Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I own the gamepass but its returning false?


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?

1 comment

0

Delete the -- on 3025376 and 1233826172, first of all.

2 answers

✓ Accepted answer

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)

1 comment

0

Don't forget to accept if this helps!

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)

5 comments

0

-1 for not giving an explanation.

0

dude srsly? i did thruout the script line 16 and 17.

0

where he whent wrong.

0

No. You did not. That doesn't explain why your solution works.

0

fine i'll just stop trying

This discussion is preserved as it was. New answers, comments, and votes are closed.