This is the script I've been trying:
local service = game:GetService("GamePassService") local id = script.Parent.Parent.Parent.TextBox.Text script.Parent.MouseButton1Click:Connect(function(player) if service:PlayerHasPass(8343910)then local sound = Instance.new("Sound") sound.Name = "Music" sound.SoundId = "rbxassetid://"..id sound.Parent = game.Workspace sound:play() else local mps = game:GetService("MarketplaceService") mps:PromptGamePassPurchase(8343910) end end)
Like the Roblox documentation says, PlayerHasPass()
is deprecated!
You should be using MarketplaceService/UserOwnsGamePassAsync
! And by the way, you would need to pass both the player and the gamepass ID, and you currently only passed the gamepass ID!
You can find the documentation for UserOwnsGamepassAsync()
here!
Updating your code should be fairly simple!
local players = game:GetService("Players") -- the player service local marketService = game:GetService("MarketplaceService") local player = players.LocalPlayer -- In client sided code, you use players.LocalPlayer to get the player script.Parent.MouseButton1Click:Connect(function() -- UserOwnsGamePassAsync takes the UserId as parameter instead of the player instance like previously if(marketService:UserOwnsGamePassAsync(player.UserId, gamepassId) then -- do your thing else -- PromptGamepassPurchase still takes the user instance as parameter marketService:PromptGamePassPurchase(player, gamepassId) end end)