How to make a script that pops up a gui and gives them a badge if they have a certain gamepass?
???
--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 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 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!
Thanks for all the help!
Sorry but I can’t give you both a solution.
1 Like