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

How could I change this?

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

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

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

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