Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The badge giver isn't working when getting 50 pride points in my game?

I have this as a script in server script service, does it have to be local? Is the script wrong?

if leaderstats.Pride_Points.Value == 50 then
	local BadgeService = game:GetService("BadgeService")
	local BadgeId = (2124623208)

	game:GetService("Players").PlayerAdded:Connect(function(player)
		local function awardBadge(player, badgeId)
			if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
				BadgeService:AwardBadge(player.UserId, badgeId)
			end
		end

2 comments

0

IsLegal and IsDisabled are both deprecated, dont use them

0

also you wrapped that into a function but you are not calling the function, is this even the complete code ?

2 answers

i have never used badge service before so i have no idea, try to see if any functions like :IsDisabled() is deprecated

I think this will work.. i never used badge service before and not tested yet

local Players = game:GetService('Players')
local BadgeService = game:GetService("BadgeService")
local BadgeId = 124214214214 -- change this to your badge id

local function Validate(BadgeId)
	local info = BadgeService:GetBadgeInfoAsync(BadgeId)
	    if info.IsEnabled then
		return true
	    else
		return
	end
end

Players.PlayerAdded:Connect(function(plr)
	local stats
	repeat wait()
		stats = plr:FindFirstChild("leaderstats"):FindFirstChild("Pride_Points")
	until stats ~= nil

	stats:GetPropertyChangedSignal("Value"):Connect(function()
		if stats.Value >= 50 then
			local sucess = Validate(BadgeId)
			if sucess then
				BadgeService:AwardBadge(plr.UserId, BadgeId)
			end
		end
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.