Hello, so I have a script in the workspace that contains this:
_G.codes = {
"TEST1",
"TEST2",
"TEST3"
}
And a LocalScript in the StarterGui that contains this:
local target = script.Parent.code
function suc()
script.Parent:TweenPosition(
UDim2.new(0, -450,0.098, 0),
"Out",
"Elastic",
2.1,
true,
function()
script.Parent.Visible = false
end)
target.Text = "<enter code here>"
end
function unsuc()
target.Text = "Code Invalid!"
wait(3)
script.Parent:TweenPosition(
UDim2.new(0, -450,0.098, 0),
"Out",
"Elastic",
2.1,
true,
function()
script.Parent.Visible = false
end)
target.Text = "<enter code here>"
end
script.Parent.submit.MouseButton1Down:Connect(function()
while _G.codes == nil do wait() end
--CODE TWO (Works)
if target.Text == _G.codes[2] then
target.Text = "Code Redeemed!"
print("Test")
local p = game.Players.LocalPlayer
local b = game:GetService("BadgeService")
b:AwardBadge(p.userId, 918606619)
wait(3)
suc()
else
unsuc()
end
--CODE ONE (Doesn't Work)
if target.Text == _G.codes[1] then
target.Text = "Code Redeemed!"
local player = game.Players.LocalPlayer
player.leaderstats.XP.Value = player.leaderstats.XP.Value + 100
wait(3)
suc()
else
unsuc()
end
--CODE THREE (Doesn't Work)
if target.Text == _G.codes[4] then
target.Text = "Code Redeemed!"
print("test")
wait(3)
suc()
else
unsuc()
end
end)
And for some reason when I enter in the correct code and hit submit, it returns the unsuc() function. Also, Code 2 works fine and the others dont. Help please!
