Gamepass = Gui pop-up + Badge (Solved)

How to make a script that pops up a gui and gives them a badge if they have a certain gamepass?:confused:
???

--Ths is a Bought Pass Badge, replace PassID with your gamepass ID, and replace 0 with your badge ID

local MPS = game:GetService("MarketplaceService")
local BadgeId = {0} 
local GP = PassID 

game.Players.PlayerAdded:connect(function(p)
	if MPS:UserOwnsGamePassAsync(p.UserId, GP) then
	    for i,Badge in pairs(BadgeId) do
      		game:GetService("BadgeService"):AwardBadge(p.UserId, Badge)
		end
	end
end)

game.StarterGUI.ScreenGUI.Frame.Visible = true

This is a gamepass badge, it awards a badge when you buy the pass

I think the game.startergui thing is wrong, but try it

1 Like

The awarding badge works. As you said, the game.startergui thing is not working.

can you tel me the error, if there is any

(replying later)

i fixed it and now it works
i will show you the script, i need to go to sleep now. It’s 1 am

1 Like

You needed to reference the player’s ‘PlayerGui’ container.

2 Likes

First, you make the gui hidden

Then, you add the script @Coolsbloxian made but with a little changes :arrow_right: ServerScriptService

local MPS = game:GetService("MarketplaceService")
local BadgeId = {0} 
local GP = PassID 

game.Players.PlayerAdded:connect(function(p)
	if MPS:UserOwnsGamePassAsync(p.UserId, GP) then
	    for i,Badge in pairs(BadgeId) do
      		game:GetService("BadgeService"):AwardBadge(p.UserId, Badge)
		end
	end
end)

Now, you put this script in from this link Script by @Forummer :arrow_right: ServerScriptService

local badges = game:GetService("BadgeService")
local userHasBadge = badges.UserHasBadgeAsync
local players = game:GetService("Players")
local player = players.LocalPlayer

local screenGui = script.Parent

local badgeId = 0 --Badge Id of owning a certain gamepass

local success, result = pcall(userHasBadge, badges, player.UserId, badgeId)
if success then
	if result then
		screenGui.Enabled = result
	end
else
	warn(result)
end

Now this should work! :smile:
Thanks for all the help!
Sorry but I can’t give you both a solution. :sob:

2 Likes