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

How to do actions after checking if the player has a gamepass or not?

Asked by
aiuis 85
6 years ago
Edited 6 years ago
local player=game.Players.LocalPlayer
local soundboard=player.PlayerGui.ScreenGui.SoundBoard
local uis=game:GetService'UserInputService'
local gps=game:GetService'GamePassService'
local ms=game:GetService'MarketplaceService'

uis.InputBegan:Connect(function(input)
    if input.KeyCode==Enum.KeyCode.B then
        if gps:PlayerHasPass(player,967732491)then
            soundboard.Visible==not soundboard.Visible
        else
            ms:PromptPurchase(player,967732491)
        end
    end
end)

What I want it to do is to check if player has a gamepass. If he/she does - show/hide the sound board and if he/she doesn't - offer him/her to buy the gamepass. But this always suggests player to buy the sound board and when he/she does buy it and press B again - it show that he/she has already bought the gamepass but not the sound board. I need your help!

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

"This method will cache its result. This means that if you call it once it will continue returning the same value, even if the user now owns the game pass in question." See the difference in uses here. Use PlayerOwnsAsset with MarketPlaceService instead.

0
Thank you. aiuis 85 — 6y
Ad

Answer this question