How do I make a twitter code GUI give out a badge?

So I have a Twitter code GUI ready for use, but in the codes’ script I wanted to make it so that if you enter a specific code it awards you a badge, how do I make such a thing?

You can use BadgeService:AwardBadge()

1 Like

You can use

if Code == "GIMME BADGE!!!!!!!!!!11" then
BadgeService:AwardBadge(Player.UserId, BadgeID)
return -- This doesnt go to the next line except for any with end in it.
end

-- Currency code stuff here. 

(In the server)

1 Like

Well, yes this is a good way but you should make it so that the player doesn’t need all the caps.

local codev1 = "codehere_dontaddanycapitals"
if Code:lower == codev1 then
BadgeService:AwardBadge(Player.UserId, BadgeID)
return -- This doesnt go to the next line except for any with end in it.
end

-- Currency code stuff here.
2 Likes
local codev1 = "codehere_dontaddanycapitals"
if Code:lower() --[[Colon methods require the parenthesis]] == codev1 then
   BadgeService:AwardBadge(Player.UserId, BadgeID)
   return 
end

Also:

local codev1 = "CODEHERE_DONTADDANYCAPITALS"

if Code:lower() == codev1:lower() then
   -- ^^ you can check if both the code entered and the actual code are the same by making them both lowercase
   BadgeService:AwardBadge(Player.UserId, BadgeID)
   return 
end
1 Like

That’s just personal preference for the OP, not yours.

1 Like