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 10 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:

01print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)
02 
03function OnTouch(part)
04    if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
05        local p = game.Players:GetPlayerFromCharacter(part.Parent)
06        if (p ~= nil) then
07            print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
08            local b = game:GetService("BadgeService")
09            b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
10        end
11    end
12end
13 
14script.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
10 years ago

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

Ad
Log in to vote
0
Answered by 10 years ago

You could use data storage too.

For an example:

01badgeID = 1 --Badge id
02 
03 
04 
05 
06game.Players.PlayerAdded:connect(function(newplr)
07 
08newplr:WaitForDataReady()
09 
10local played_before = Instance.new("BoolValue", newplr)
11 
12played_before.Name = "D3D"
13 
14played_before.Value = false
15 
View all 34 lines...

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

Answer this question