If statement isn't working properly

Hi! So I made it so there is an event that is triggered and it this script reacts to it:


local rep = game:GetService('ReplicatedStorage')
local ToolSelectedRE = rep.Win
local badgeid = 2127907418

ToolSelectedRE.OnServerEvent:Connect(function(player)
	print("yo")
	if game.BadgeService:UserHasBadgeAsync(player.UserId, badgeid) then
		print("hi")
		game.BadgeService:AwardBadge(player.UserId, badgeid)

		player.leaderstats.Coins.Value += 50
		player.leaderstats.Skips.Value += 1
	end
end)

The problem is, the if statement in this script doesn’t work, so even if a player 100% doesn’t own that badge, the if statement won’t be passed through. How do I fix this?

Your script checks if the user owns the badge, and if they do, it continues. Simply add a not to your if statement as seen below.

	if not game:GetService("BadgeService"):UserHasBadgeAsync(player.UserId, badgeid) then
1 Like