local bgs = game:GetService("BadgeService")
local id = 2128017553
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local cust = leaderstats:WaitForChild("Custards")
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
onChange = cust.Changed:Connect(function()
if cust.Value >= 10 then
if hum.Health == 100 then
if not bgs:UserHasBadgeAsync(player.UserId, id) then
bgs:AwardBadge(player.UserId, id)
end
end
end
end)
end)
it still gives out badge even if i have less than 100 hp
Can the players heal? For example, if I get damaged during the round, and heal up to 100 health, do you still want to give them the badge? (only if they can heal in your game)
--//Services
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
--//Controls
local badgeId = 2128017553
--//Functions
local function AwardBadge(player, badgeId)
local success, errorMessage = pcall(function()
BadgeService:AwardBadge(player.UserId, badgeId)
end)
if not success then
warn(errorMessage)
end
end
Players.PlayerAdded:Connect(function(player)
local custards = player:WaitForChild("leaderstats"):WaitForChild("Custards")
custards.Changed:Connect(function(newValue)
if newValue < 10 then
return
end
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if not humanoid or humanoid.Health < 100 then
return
end
if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId) then
AwardBadge(player, badgeId)
end
end)
end)
--//Services
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
--//Controls
local badgeId = 2128017553
--//Functions
local function AwardBadge(player, badgeId)
local success, errorMessage = pcall(function()
BadgeService:AwardBadge(player.UserId, badgeId)
end)
if not success then
warn(errorMessage)
end
end
Players.PlayerAdded:Connect(function(player)
local custards = player:WaitForChild("leaderstats"):WaitForChild("Custards")
custards.Changed:Connect(function(newValue)
if newValue < 10 then
return
end
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if not humanoid or humanoid.Health < humanoid.MaxHealth then
return
end
print("Health:", humanoid.Health)
print("MaxHealth:", humanoid.MaxHealth)
if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId) then
AwardBadge(player, badgeId)
end
end)
end)
a better solution for this would be, a individual value called: “NoHit” boolvalue
then create a function detecting the health of the user
if somehow the health changes to something negative or below 100,
Nohit = true, then, after finishing the round, check if NoHit is FALSE, if FALSE, then give the badge, that means the user never lost Health
can be a intvalue from ''instance.new" or can be saved internaly if you got some datastore, but when the player joins the game again, make sure to Turn [NoHit] to false again, by default