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

Is there is any way to fix this problem?

Asked by
mine248 40
9 years ago

So I wrote a code, and I tested it.

script.Parent.Frame.TextButton.MouseButton1Click:connect(function()
    if script.Parent.Frame.TextLabel.Text == "Hello! I'm mine248 and I'll be teaching you how to operate this train." then
        script.Parent.Frame.TextLabel.Text = "Press the up key or W to go forwards."
    elseif script.Parent.Frame.TextLabel.Text == "Press the up key or W key to go forwards." then
        script.Parent.Frame.TextLabel.Text = "Press the down key or S key to go forwards."
    elseif script.Parent.Frame.TextLabel.Text == "Press the down key or S key to go forwards." then
        script.Parent.Frame.TextLabel.Text = "Go open the door, on the side the platform is at (a big peice of block)."
    elseif script.Parent.Frame.TextLabel.Text == "Go open the door, on the side the platform is at (a big peice of block)." then
        script.Parent.Frame.TextLabel.Text = "Then wait until the timer counts to 1."
    end
end)

I t would work from lines 1-3, then fail on the other. Is there a error that did it?

0
Any output? Lacryma 548 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

You have different strings on line 3 and 4. To avoid this, use a variable or table:

local instructions = {
    "Hello! I'm mine248 and I'll be teaching you how to operate this train.",
    "Press the up key or W to go forwards.",
    --etc
}
local step = 1
script.Parent.Frame.TextButton.MouseButton1Click:connect(function()
    script.Parent.Frame.TextLabel.Text = instructions[step] 
    step = (step % #instructions) + 1
end
Ad

Answer this question