Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

"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.

1 comment

0

Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.