Hey everyone, so I’m starting to finish up on my game. It’s an obby, and there are certain parts where I want to reward the player with a badge. I got the awarding player when they join down, but I’m not sure how to make it work when it touches something. Here is my script. I couldn’t find any errors.
local BadgeService = game:GetService("BadgeService")
local id = 2124620845
local badgegive = game.Workspace.BadgeSkeleton
badgegive.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.Players.PlayerAdded:Connect(function(plr)
if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
BadgeService:AwardBadge(plr.UserId, id)
end
end)
end
end)
not sure if I need to use
local Players = game:GetService("PlayerService")
if any of you have an idea, please let me know! Thanks :))
if you wanted to know, the skeleton is in a group.
local BadgeService = game:GetService("BadgeService")
local id = 2124620845
local badgegive = game.Workspace.BadgeSkeleton
badgegive.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
BadgeService:AwardBage(plr.UserId, id)
end
end
end)
Also, your problem was, when someone stepped on the part that is supposed to award the badge, anyone that joined after them, would be awarded the badge on join if they didn’t already have it. So, instead, you need to get the player that touched the part and award them the badge.