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

How could I change this?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I want this badge awarded when a player enters a game. Here is the default script:

print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)

function OnTouch(part)
    if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
        local p = game.Players:GetPlayerFromCharacter(part.Parent)
        if (p ~= nil) then
            print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
            local b = game:GetService("BadgeService")
            b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
        end
    end
end

script.Parent.Touched:connect(OnTouch)

How could I change it so that when you join the game, you automatically get the badge?

2 answers

Log in to vote
0
Answered by
Emg14 10
9 years ago

Thread will be closed. To start a new question or thread please do so!

Ad
Log in to vote
0
Answered by 9 years ago

You could use data storage too.

For an example:

badgeID = 1 --Badge id




game.Players.PlayerAdded:connect(function(newplr)

newplr:WaitForDataReady()

local played_before = Instance.new("BoolValue", newplr)

played_before.Name = "D3D"

played_before.Value = false

newplr:LoadBoolean("player_check")

if not played_before then

game:GetService("BadgeService"):AwardBadge(newplr.userID,badgeID)

played_before = true
else

played_before = true

end

end) 
game.Players.PlayerRemoving:connect(function(oldplr)

oldplr:SaveBoolean("player_check", oldplr.D3D.Value)

end)

Ofcourse you would need some data presistence, annonymous function knowledge, but thats how i would've create it

Answer this question