Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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
0
IsLegal and IsDisabled are both deprecated, dont use them VerdommeMan 1479 — 4y
0
also you wrapped that into a function but you are not calling the function, is this even the complete code ? VerdommeMan 1479 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

Ad
Log in to vote
0
Answered by
174gb 290 Moderation Voter
4 years ago
Edited 4 years ago

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)

Answer this question