Overhead Gamepass not working

Hello,

I was making a VIP overhead gui but I didn’t work
I tried following AlvinBlox’s YT video but it didn’t work
I checked for mistakes from the script but there are no mistakes
I also made another gamepass just incase still doesn’t work

script:

local tag = game:GetService("ServerStorage"):WaitForChild("VipTag") -- vip tag
local memtag = game:GetService("ServerStorage"):WaitForChild("AgorpMember") -- group member tag

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, 21671832) then
			local clone = tag:Clone()
			clone.Parent = game.Workspace:WaitForChild(plr.Name).Head
		elseif plr:IsInGroup(9989970) then
			local clone1 = memtag:Clone()
			clone1.Parent = game.Workspace:WaitForChild(plr.Name).Head
		end
	end)
end)

thanks in advance :slight_smile:

1 Like

Try using MarketplaceService | Roblox Creator Documentation instead of PlayerOwnsAsset

1 Like

It doesn’t work I reseting my character still doesn’t work

also i received a error

Unable to cast Instance to int64

UserOwnsGamePassAsync requires the player’s UserId and not the player itself

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21671832) then

like this?

Edit:
it still doesn’t work : (
this time no errors

Either

  1. You don’t own the gamepass (for some reason, maybe you used the wrong Gamepass Id?)
  2. The nametag isn’t being cloned into your character’s head (when your character loads check if the BillboardGui is even there)

also yes you did it correctly

1 Like

I did everything you told
I checked if the gui is disabled [it’s enabled]
I checked if got the wrong gamepass [it’s the right gamepass and also it’s on sale]

I tested your script and it worked perfectly fine for me. This is a very important question.

Is your script a LocalScript?

It’s a server script
stored in serverscript

(ignore this char chair chair)

I’m not sure about this but
I checked if the gui is really stored the head and it isn’t
I checked it in the explorer

Okay, so I looked up the the ID of the gamepass and it wasn’t a gamepass. It was a decal image.
Nevermind it was a valid gamepass, but I don’t think you own it.

and NEVERMIND that because I just saw the new image

too lazy to crop it sorry

I’m a bit confused, try this (I only added a print, check them in the Output)

local tag = game:GetService("ServerStorage"):WaitForChild("VipTag") -- vip tag
local memtag = game:GetService("ServerStorage"):WaitForChild("AgorpMember") -- group member tag

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21671832) then
			print("gamepass owned")
            local clone = tag:Clone()
			clone.Parent = game.Workspace:WaitForChild(plr.Name).Head
		elseif plr:IsInGroup(9989970) then
			local clone1 = memtag:Clone()
			clone1.Parent = game.Workspace:WaitForChild(plr.Name).Head
		end
	end)
end)

the print doesn’t work

i’ll try removing the group thing and make it in a separate script

nono, the group thing is not the problem. you don’t own the gamepass.

How about PromptGamePassPurchaseFinished?

Sorry to butt in, but I believe the problem is because you’re purchasing it mid game. Your script checks when the first character is added and then that result gets cached on Roblox so that the server can access it faster instead of making a call every time.

And the easy solution would be to store if a player purchased it in that server, and if they did, to then give it to them.

local bought = {} --Empty table

local tag = game:GetService("ServerStorage"):WaitForChild("VipTag") -- vip tag
local memtag = game:GetService("ServerStorage"):WaitForChild("AgorpMember") -- group member tag

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21671832) or bought[player.UserId] then --Check if they own the gamepass, or if they bought it in this server.
			local clone = tag:Clone()
			clone.Parent = char.Head
		elseif plr:IsInGroup(9989970) then
			local clone1 = memtag:Clone()
			clone1.Parent = char.Head
		end
	end)
end)

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(player, gamepassId, purchased)
  if gamepassId == 21671832 then --Check that it's the vip gamepass
    bought[player.UserId] = purchased --Add into the table to show whether it was purchased or not (a boolean value) so we can check when the character is added.
    --Add your code from above down here to add the tag if you want it to give it to them right away vs waiting for them to respawn.
  end
end)

Ohh, I thought he was trying to find out why the Tag wasn’t put on his character when he joined the server

So it doesn’t workin in-studio but work in-game?

If you use the code I provided, it will work in both!
The problem (should) just be that you aren’t storing that the player purchased it, and instead are just using the cached Roblox API result saying that they don’t own it. So even when they purchase it mid game, it will still show that they don’t own it.

@DumbHeadEdison Yes, it’s because he doesn’t have it when he joins, but in the pictures he sent, he was trying to purchase it mid game and it wasn’t giving it to him.