im making a gasa4 like game and I want to display which ending the player has with badges
I have a ui that has all the endings in boxes and the text in each box is ??? until you get the badge then it turn to the name of the ending
heres a code that I have but the problem is that it changes the text even if the player doesnt have the badge
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2130284698
local function checkBadge(player, BadgeId)
local succes, badge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId)
end)
return badge
end
script.Parent.Text = "Capybara"
local BadgeService = game:GetService("BadgeService")
while true do
wait()
if BadgeService:UserHasBadgeAsync(UserId, BadgeId) then
script.Parent.Text = "Text"
else
script.Parent.Text = "Othertext"
end
end
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2130284698
while true do
wait(0.5)
if BadgeService:UserHasBadgeAsync(player, BadgeId) then
script.Parent.Text = "Capybara"
else
script.Parent.Text = "Change to text if doesn't have badge"
end
end
Alright try it now…I belive player does not need defined. If not you might just have to make a variable for the player, off the top of my head I dont know what that would be
i did this still doesnt work though
ima try it not in studio
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2130284698
local Player = game:GetService("Players")
while true do
wait(0.5)
if BadgeService:UserHasBadgeAsync(Player, BadgeId) then
script.Parent.Text = "Capybara"
else
script.Parent.Text = "???"
end
end
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2130284698
while true do
wait()
if BadgeService:UserHasBadgeAsync(player, BadgeId) then
script.Parent.Text = "Capybara"
else
script.Parent.Text = "???"
end
end