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.

01function assign(property, player)
02    local GUI = game.ReplicatedStorage:FindFirstChild("Gamepass"..property):GetChildren()
03    for i = 1,#GUI do
04        GUI[i]:Clone().Parent = player.PlayerGui.ScreenGui.Avatar:FindFirstChild(property)
05    end
06end
07 
08 
09game.Players.PlayerAdded:Connect(function(player)
10    player.CharacterAdded:Connect(function(character)
11        wait(0.1)
12        if game:GetService("GamePassService"):PlayerHasPass(player, 4950898) then
13            assign("Colors",player)
14            assign("Faces",player)
15        end
16    end)
17end)

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.

01function assign(property, player)
02    local GUI = game.ReplicatedStorage:FindFirstChild("Gamepass"..property):GetChildren()
03    for i = 1,#GUI do
04        GUI[i]:Clone().Parent = player.PlayerGui.ScreenGui.Avatar:FindFirstChild(property)
05    end
06end
07 
08 
09game.Players.PlayerAdded:Connect(function(player)
10    player.CharacterAdded:Connect(function(character)
11        wait(0.1)
12        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.
13            assign("Colors",player)
14            assign("Faces",player)
15        end
16    end)
17end)

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