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

This is for a Twitter code gui, but it does the redeem, but it doesn't do the already redeemed?

This is for a Twitter code gui, but it does the redeem, but it doesn't do the already redeemed.

local CodeBox = script.Parent.Parent:WaitForChild("CodeBox")
local Player = game.Players.LocalPlayer
local CodeOne = "OOF"

function onClick()
	if Player.RedeemOne.Value == false then
		if CodeBox.Text == "OOF" then
			Player.RedeemOne.Value = true
			CodeBox.Text = "Redeemed!"
			Player.Points.Value = Player.Points.Value + 1000
			wait(2)
			CodeBox.Text = "Insert Code Here!"
		elseif Player.RedeemOne.Value == true then
			CodeBox.Text = "Already used!"
			wait(2)
			CodeBox.Text = "Insert Code Here!"
			
			
	end
	end
	end
script.Parent.MouseButton1Click:Connect(onClick)

5 comments

0

I recommend making the script check a site for the code, so you dont have to manually code it in and make old servers not be able to use it.

0

@hiimgoodpack, I just need this to work, I don't really mind that stuff. If you could find a solution that would be great.

0

The elseif statement on line 13 is inside the if statement on line 6 and apart of the if statement on line 7 when it should be apart of the if statement on line 6. The script checks to seem if RedeemOne is false, then after checking the text it checks to see if RedeemOne is true. It can never be true if it was already checked in the same if statement to see if it was false.

0

Bottom line is that line 13 needs to be outside the if statement on line 7, after the end for that statement. Indenting your ends will make it easier to catch this next time.

0

@hawkkingdom can you edit the script in a answer? please

1 answer

✓ Accepted answer

You put the elseif statement in the wrong place. It should be like this.

local CodeBox = script.Parent.Parent:WaitForChild("CodeBox")
local Player = game.Players.LocalPlayer
local CodeOne = "OOF"

function onClick()
    if Player.RedeemOne.Value == false then
        if CodeBox.Text == "OOF" then
            Player.RedeemOne.Value = true
            CodeBox.Text = "Redeemed!"
            Player.Points.Value = Player.Points.Value + 1000
            wait(2)
            CodeBox.Text = "Insert Code Here"
         end
    elseif Player.RedeemOne.Value then
            CodeBox.Text = "Already used!"
            wait(2)
            CodeBox.Text = "Insert Code Here!"
         end
    end
script.Parent.MouseButton1Click:Connect(onClick)

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