The purpose of this script is to give the player a billboard GUI above their head if they have purchased the relevant gamepass. When using the script without the gamepass check, it works perfectly fine and the GUI is cloned into my character’s head. I have looked at other dev forum posts and videos but the solutions in those haven’t worked either.
Script:
local marketplaceService = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local ownsPass = marketplaceService:UserOwnsGamePassAsync(player.UserId, 5069872012)
if ownsPass == true then
local VIPGui = game.ServerStorage.VIPGui:Clone()
VIPGui.Parent = character.Head
end
end)
end)
I would be very grateful if someone could help me figure this out.
Make sure you got the pass ID completely right, one small number can make it go all wrong.
Do you actually own the gamepass? That’s another reason.
Also, UserOwnsGamePassAsync should be wrapped in a pcall, I’m pretty sure.
local mps = game:GetService("MarketplaceService")
local success, owned = pcall(mps.UserOwnsGamePassAsync, mps, player.UserId, --[[gamepass ID here]])
if success and owned then
--do stuff because they own it
elseif not success then
player:Kick("Failed to retrieve gamepass data. Please rejoin!")
else
--they don't own the pass.
end