Script breaks nametag

This breaks the script, any ideas on why?

There is a folder inside the script called Badges and the image name is priority. (not my script)

1 Like

So it’s essentially calling a function within an if statement. It should be game:GetService("MarketplaceService"):UserOwnsGamePassAsync(TheirUserId, GamepassId)

What it’s doing is calling an unknown function, with random numbers, which returns nothing. So it breaks the script.

If you need more explanation, please ask.

For the “TheirUserId” would that need to be replaced?

what ever you called the player.

ex:

local plr = game.Players.LocalPlayer

plr.UserID

Essentially. I’ll give a breakdown.

the service MarketplaceService allows you to check when people buy gamepasses, own them, anything of the sort regarding devproducts/gamepasses.
I’ll explain:

local MP = game:GetService("MarketplaceService") --MP now automatically means that variable, making it easier for me to write the script.

if MP:UserOwnsGamepassAsync(PersonWhoBought.UserId, GamepassId) then --So we need the userId of the played to check if they own the gamepass, then we need to know the gamepass Id, or else how are we supposed to know what to check?

end)

When you do BlahBlah() and have two parenthesis at the end without defining a service, or a specific function like “:Destroy()” or “:Clone()”, it’ll attempt to trigger a function. In your case, a function is a pre-defined set of things to do. The problem is that they tried to call a non-existent function. So yes this needs changing.

Would the script be:

`game:GetService("MarketplaceService"):UserOwnsGamePassAsync(TheirUserId, 17858602)` then

local Priority = script.Priority.Badges:Clone()

Priority.Parent = ui.Frame

end

Or is that incorrect, sorry if I’m being confusing.

You need to provide the player userid as an argument for the UserOwnsGamePassAsync() function to work. As you see the attached script gets the player when one connects and uses that to check ownership. Not sure about your spesific use but make sure you get the player you want to check if owns the gamepass and use their userid as the first argument of the function. Also do it in a server script if you aren’t already.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local Priority = script.Priority.Badges:Clone()

Players.PlayerAdded:Connect(function(Player)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,17858602) then
		Priority.Parent = ui.Frame
	end
end)