Im trying to check if the player is added, to add the LocalPlayer variable
Though it doesn’t work, there isnt an output error aswell.
local b = game:GetService("BadgeService")
-- EDIT THIS--
local datavalue = "HasEggdog"
game.Players.PlayerAdded:Connect(function(plr)
local checker = plr:WaitForChild('Data'):WaitForChild(datavalue).Value
local badgeid = script.Parent.BadgeID.Value
if b:UserHasBadgeAsync(plr.UserId, badgeid) then
print(plr.Name .. " has badge " .. badgeid)
checker = true
else
checker = false
end
end)
EDIT I forgot to mention this:
This code will check if the player has the badge and if the player does it prints a message in the output, if the player doesn’t, it will print a different message in the output. This coding example may help so you can implement your own system into this coding example I have provided.
Basic Example:
local badgeService = game:GetService("BadgeService")
local players = game:GetService("Players")
local badgeID = 123456 -- Enter your badge ID here
players.PlayerAdded:Connect(function(player)
if badgeService:UserHasBadgeAsync(player.UserId, badgeID) then
print("Has badge")
else
print("Does not have badge")
end
end)
local b = game:GetService("BadgeService")
-- EDIT THIS--
local datavalue = "HasEggdog"
game.Players.PlayerAdded:Connect(function(plr)
local checker = plr:WaitForChild('Data'):WaitForChild(datavalue)
local badgeid = script.Parent.BadgeID.Value
if b:UserHasBadgeAsync(plr.UserId, badgeid) then
print(plr.Name .. " has badge " .. badgeid)
checker.Value = true
else
checker.Value = false
end
end)