Badge checking portion of script not working

I’ve very recently started a new project after being inactive for a while and i have made a part which gives a player a badge when they touch it and while the player gets the badge if they touch the part when they already have that badge and join back the part stays for them which it shouldn’t.

I’ve tested it in studio and on the game itself because badges don’t really work with studio but it still doesn’t work and i need this to work for future additions for this part of the script.

Plz help a little poor boy fixing his small bit of code, i also don’t get the print which makes me know that the player or badge just isn’t being detected.

The code
-- Badgeid set in variable

game:GetService("Players").PlayerAdded:Connect(function(plr)
	if badgeservice:UserHasBadgeAsync(badgeid) then
		print(plr.Name.." had the badge")
		script.Parent.CanCollide = false
		script.Parent.Transparency = 1
		script.Enabled = false
	end
end)

When doing :UserHasBadgeAsync(badgeid) you should pass the player’s UserId as a parameter first. Try doing this:

if badgeservice:UserHasBadgeAsync(plr.UserId, badgeid) then
2 Likes

Thank you, i had no idea how i didn’t spot that when i had even used that for the touch detection part of the script.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.