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

CodeBox is not a valid member of ScreenGui Why is this happening?

local button = script.Parent.Parent
local box = button.Parent.CodeBox
local code = "Code"
local code2 = "Code2"
local code3 = "Code3"
local redeedmed = false


button.MouseButton1Click:Connect(function(plr)
	if box.Text == code and redeedmed == false then
		redeedmed = true
		button.Text = "Success"
		game.Players.LocalPlayer.Strength.Value = game.Players.LocalPlayer.Strength.Value + 50
		game.Players.LocalPlayer.Money.Value = game.Players.LocalPlayer.Money.Value + 25
		wait(2)
		button.Text = "Submit"
		return true
    end
	if box.Text == code2 and redeedmed == false then
		redeedmed = true
		button.Text = "Successfully redeemed!"
		game.Players.LocalPlayer.Strength.Value = game.Players.LocalPlayer.Strength.Value + 50
		game.Players.LocalPlayer.Money.Value = game.Players.LocalPlayer.Money.Value + 25
		wait(2)
		button.Text = "Submit"
		return true
	end
	if box.Text == code3 and redeedmed == false then
		redeedmed = true
		button.Text = "Successfully redeemed!"
		game.Players.LocalPlayer.Strength.Value = game.Players.LocalPlayer.Strength.Value + 50
		game.Players.LocalPlayer.Money.Value = game.Players.LocalPlayer.Money.Value + 25
		wait(2)
		button.Text = "Submit"
		return true
	else
		button.Text = "Invalid"
		wait(2)
		button.Text = "Submit"
		return false
	end
end)

1 answer

✓ Accepted answer

Did you check if your pathing was correct? If it was correct, please use WaitForChild as the TextBox may not be ready when the script runs.

1 comment

0

Nothing worked for me but thank you Vong25

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