I'm making a game, and I want a player to obtain a badge when they put a code inside a code menu, and when they click the button, the script checks if the text is correct, and if it is, it awards the badge. But its not awarding the badge!
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.TextBox.Text == "placeholder" then
local Player = game.Players.LocalPlayer
local badgeid = 2123496874
local BadgeService = game:GetService("BadgeService")
if not BadgeService:UserHasBadge(Player.UserId,badgeid) then
BadgeService:AwardBadge(Player.UserId,badgeid)
script.Parent.Parent.TextBox.Text = "REDEEMED"
wait(1.5)
script.Parent.Parent.TextBox.Text = ""
end
end
end)
Whenever I try this in-game, the text changes to REDEEMED, as it should, but doesn't award the badge. Any help?

1 comment
The server should be ginig the badge not the player. You also do not want to test on the client side.