In my game I wanted to have players receive items for having a badge, I took a script that did this but with game passes instead of badges and changed it up so it would work with badges, the problem is, the script does not work, after fiddling with is for a while I decided that I should come here for help with the script. Any assistance would be greatly appreciated, here is the script:
id = 12312321 --Badge id game.Players.PlayerAdded:connect(function(plr) repeat wait() until plr.Character if game:GetService("BadgeService"):PlayerHasBadge(plr, id) then local tool = game.ServerStorage["Dream Bat"] tool:clone().Parent = plr.Backpack tool:clone().Parent = plr.StarterGear end end)
I identified the problem very quickly.
You said PlayerHasBadge when the real method is UserHasBadge. Look here for more information. Try using this code:
id = 12312321 --Badge id game.Players.PlayerAdded:connect(function(plr) repeat wait() until plr.Character if game:GetService("BadgeService"):UserHasBadge(plr, id) then local tool = game.ServerStorage["Dream Bat"] tool:clone().Parent = plr.Backpack tool:clone().Parent = plr.StarterGear end end)
Please accept my answer if it worked. Thank you!