hello developers i have something to ask you today that may seem like a stupid thing to ask BUT, do any of you know how to make a
“when you die you get a badge script”
it for the sword fight arena in my game.
pls let me know asap.
–teyougin
hello developers i have something to ask you today that may seem like a stupid thing to ask BUT, do any of you know how to make a
“when you die you get a badge script”
it for the sword fight arena in my game.
pls let me know asap.
–teyougin
You’re going to want to create the badge in the first place. That’s pretty simple, just google “How to make a badge roblox”.
Once you do that, you’re going to want a script that detects when the player dies. Use Humanoid.Died event: Humanoid.Died
When the Humanoid dies, detect if they actually died to a player (Use combat tagging of some sort)
If they do die to a player (rather than falling off the map or resetting), then grant them a badge with BadgeService:AwardBadge
LocalScript
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function(tag)
local BadgeService = game:GetService("BadgeService")
local BadgeId = Id Here
BadgeService:AwardBadge(game.Players.LocalPlayer.UserId, BadgeId)
end)
1- Use Humanoid.Died() event to detect when the player died.
2- Use pcalls
to give the player the badge.
Badges can not be awarded from a local script.
Plus, he wants the badge to given when they die.
then just make script with the little bit changed code in starterplayerscripts
Humanoid.Died Be like lol isn’t that died event
it is died:Connect(function() if you can’t read
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
end)
end)
end)
I already knew that
Died is an event:)
The argue was about “died”.
okay thank you i will try this when i work on my game this weekend. once again ty ty ty ty
make sure to change it little bit and then transform into script
i would do that but i don’t have roblox studio opened so ye
what do you mean? i suck at scripting btw that’s why i asks for such a stupid thing.
wait little bit i will make script really quickly in roblox studio
okay take all the time you need.
local BadgeService = game:GetService("BadgeService")
local BadgeID = 000000 -- put your badgeID here
local userHasBadge = BadgeService.UserHasBadgeAsync
local awardBadge = BadgeService.AwardBadge
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
Char.Humanoid.Died:Connect(function()
local success, result = pcall(userHasBadge, BadgeService, Player.UserId, BadgeID)
if success then
local check2, result2 = pcall(awardBadge, BadgeService, Player.UserId, BadgeID)
if check2 then
BadgeService:AwardBadge(Player.UserId,BadgeID)
end
end
end)
end)
end)
there is easier version which works aswell
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
plr.Character.Humanoid.Died:Connect(function(tag)
print("Died")
local BadgeService = game:GetService("BadgeService")
local BadgeId = 1
BadgeService:AwardBadge(plr.UserId, BadgeId)
end)
end)
end)
make script and then place it in workspace
here is code for script
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
plr.Character.Humanoid.Died:Connect(function(tag)
print("Died")
local BadgeService = game:GetService("BadgeService")
local BadgeId = 1
BadgeService:AwardBadge(plr.UserId, BadgeId)
end)
end)
end)