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

When I change the text, it doesn't start?

Asked by
iFurzy 35
7 years ago

I have a textbox that when I start out with something other than "Begin1," and then change it to "Begin1," doesn't work. It only works when I press "Test" with the text as "Begin1."

while true do

    wait()

    if game.StarterGui.Group.TextBox.Text == "Begin1" then

        script.Parent.Text = "Right face!"
        wait(10)
        script.Parent.Text = "Eyes up front!"
        wait(10)
        script.Parent.Text = "Left face!"
        wait(10)
        script.Parent.Text = "Eyes up front!"
        wait(10)
        script.Parent.Text = "About face!"
        wait(10)
        script.Parent.Text = "Eyes up front!"
        wait(10)

    end
end

1 answer

Log in to vote
0
Answered by 7 years ago

Your error is simple. The problem is you are calling on the TextBoxthat is located in StarterGui, and not the one that is located in your player. The easiest way to fix this, is to just replace StarterGuiwith the PlayerGui

Here is an example:

local name = "" -- Just put your name here!

while wait() do
    local plr = game.Players:FindFirstChild(name)
    if plr ~= nil then --This just makes sure the player is actually in the game
        local p_gui = plr.PlayerGui -- PlayerGui is the gui for each individual player in the game
        if p_gui ~= nil then
            if p_gui.Group.TextBox.Text == "Begin1" then
                script.Parent.Text = "Right face!"
                wait(10)
                script.Parent.Text = "Eyes up front!"
                wait(10)
                script.Parent.Text = "Left face!"
                wait(10)
                script.Parent.Text = "Eyes up front!"
                wait(10)
                script.Parent.Text = "About face!"
                wait(10)
                script.Parent.Text = "Eyes up front!"
                wait(10)
            end
        end
    end
end

I hope this helped!

Ad

Answer this question