Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
Edited by JesseSong 3 years ago
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

Log in to vote
1
Answered by 3 years ago

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.

0
Nothing worked for me but thank you Vong25 unicol45 7 — 3y
Ad

Answer this question