Is their anyway make this checking every 2 seconds, because now it only counts when an player joins but I have over 150 badges so when an player find a new one i want the value goes up but now it doesn't check agian each 2 seconds. Someone know how? Btw I do like to not change line 2 beacuse I already did put in the orginal one 150 badges. Thanks alot!
local BadgeService = game:GetService("BadgeService") local badges = {229929415, 229929797, 229929912} while true do wait (2) local function countBadges(player) local numBadges = 0 for _, badge in next, badges do if BadgeService:UserHasBadge(player.userId, badge) then numBadges = numBadges + 1 end end return numBadges end game.Players.PlayerAdded:connect(function(player) local stats = player:WaitForChild("leaderstats") local cash = stats:WaitForChild("Badge") cash.Value = countBadges(player) end) end
local BadgeService = game:GetService("BadgeService") local badges = {229929415, 229929797, 229929912} local function countBadges(player) local numBadges = 0 for _, badge in next, badges do if BadgeService:UserHasBadge(player.UserId, badge) then numBadges = numBadges + 1 end end return numBadges end game.Players.PlayerAdded:connect(function(player) local stats = player:WaitForChild("leaderstats") local badgeCount = stats:WaitForChild("Badge") badgeCount.Value = countBadges(player) while wait(2) do badgeCount.Value = countBadges(player) end end)
This might work:
function countBadges(player) local numBadges = 0 for _, badge in next, badges do if BadgeService:UserHasBadge(player.userId, badge) then numBadges = numBadges + 1 end end return numBadges end local BadgeService = game:GetService("BadgeService") local badges = {229929415, 229929797, 229929912} game.Players.PlayerAdded:connect(function(player) local stats = player:WaitForChild("leaderstats") local cash = stats:WaitForChild("Badge") cash.Value = countBadges(player) while true do wait (2) countBadges(player) end end)