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

How do you make a badge reward when you reach like 2500 Strength? [closed]

Asked by 7 years ago

I was wondering how you make a badge reward the person when they reach 2500 strength.

Closed as Not Constructive by Goulstem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

To award the badge, you can use the AwardBadge function of BadgeService.

Do this in a Changed event on the player's Strength stat, with an if statement to determine if they have 2500 strength.

In a Script:

local badges = game:GetService("BadgeService")
local badge = 000000 --Your badge
local wantedVal = 2500 --Amount to earn badge

game.Players.PlayerAdded:Connect(function(plr)
    local value = plr:WaitForChild("Strength") --The stat
    value.Changed:Connect(function(val)
        --Don't check if they already own it
        if badges:UserHadBadge(plr.UserId,badge) then return end
        if val >= wantedVal then --Compare the val
            badges:AwardBadge(plr.UserId,badge) --Award the badge
        end
    end)
end)
0
It doesn't work MemeSnakex -3 — 7y
Ad