Ad
Log in to vote
0

My game pass for some reason isn't working. It's confusing, can anybody help me?

Asked by 3 days ago

Made a gamepass script, not sure why it doesn't work. I typed everything out correctly and it is a normal script in the workspace. Please help ;-; the ID is correct and so is everything else im confused.

local id = 5360272

game.Players.PlayerAdded:Connect(function(player)
    wait(2)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print(player.Name .. " has gamepass")
        game.ReplicatedStorage.ParticleEffect:Clone().Parent = player.Character.Head
    else
        print(player.Name .. " has no gamepass")
    end
end)

1 answer

Log in to vote
0
Answered by 3 days ago
Edited 3 days ago

The problem is you're using GamePassService.PlayerHasPass, which is broken and outdated now. An update was made to game passes in April of this year which made them their own category; they are no longer assets. You must now use the MarketplaceService.UserOwnsGamePassAsync method.

local id = 5360272
local MarketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    wait(2)
    if MarketplaceService:UserOwnsGamePassAsync(player.UserId, id) then 
        print(player.Name .. " has gamepass")
        game.ReplicatedStorage.ParticleEffect:Clone().Parent = player.Character.Head
    else
        print(player.Name .. " has no gamepass")
    end
end)

Note that this method takes the UserId of the player as first argument, and not the player object itself.


Hopefully this answered your question and if it did then don't forget to hit that accept button. If you have any other questions then feel free to leave them in the comment section below.
Ad

Answer this question