You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make it so that when a player touches a part they get a badge but ONLY if they are alive. -
What is the issue? Include screenshots / videos if possible!
It’s a bit difficult for me to test it so I’m trying to get feedback on a script I already have to make sure it would work. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I don’t think I would be able to test it here by looking at other topics. I might be able to find a script that works but I don’t want to make a entire new script when I have one that already works considering I had many issues awarding a player a badge when they touch a part in the first place.
Here is the script that I have:
local __BADGESERVICE = game:GetService("BadgeService")
local __PLAYERS = game:GetService("Players")
local __ID = 2140926703 -- !! REPLACE
script.Parent.Touched:Connect(function(__PART)
local __PLAYER = __PLAYERS:GetPlayerFromCharacter(__PART.Parent)
local humanoid = __PART.Parent:FindFirstChild("Humanoid")
if not humanoid then
return end
if __PLAYER ~= nil and (not humanoid.Health) == 0 then
print("Here is your badge")
__BADGESERVICE:AwardBadge(__PLAYER.UserId, __ID)
end
end)
I haven’t gotten a confirmation that this works yet or a correction on something. I can’t tell if I should use if
or else if
on line 10 of the script.