Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Game pass script not functioning?

Asked by 6 years ago

Hi there, back with another question! I can't see the error in this script I wrote, which allows for a player with a game pass to be assigned a GUI.

function assign(property, player)
    local GUI = game.ReplicatedStorage:FindFirstChild("Gamepass"..property):GetChildren()
    for i = 1,#GUI do
        GUI[i]:Clone().Parent = player.PlayerGui.ScreenGui.Avatar:FindFirstChild(property)
    end
end


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        wait(0.1)
        if game:GetService("GamePassService"):PlayerHasPass(player, 4950898) then 
            assign("Colors",player)
            assign("Faces",player)
        end
    end)
end)


Any help is appreciated, thanks scripters!

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

I'm assuming the error is on line 12. The PlayerHasPass method has been deprecated not too long ago, so you'll need to update it using MarketplaceService's UserOwnsGamePassAsync.

function assign(property, player)
    local GUI = game.ReplicatedStorage:FindFirstChild("Gamepass"..property):GetChildren()
    for i = 1,#GUI do
        GUI[i]:Clone().Parent = player.PlayerGui.ScreenGui.Avatar:FindFirstChild(property)
    end
end


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        wait(0.1)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 4950898) then -- Instead of giving the player's instance in the first argument, we pass the player's user id.
            assign("Colors",player)
            assign("Faces",player)
        end
    end)
end)

Sources: https://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/UserOwnsGamePassAsync

If you have any problems with this script, let me know in the comments. If it works and you're satisfied, be sure to accept the answer!

0
It works! Thanks a lot! SnazzySpider67 53 — 6y
Ad

Answer this question