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

Why am I getting an error when trying to change the state of this variable?

Asked by 4 years ago

I have some signs assigned to a part in a model. They show the current active game mode. However, when I try to change the state of variable Text1, as well as Text2,Text3 and Text4, it shows an error for Variable Text1. Here is the entire script, as variables are declared in the first few lines.

local Text1 = script.Parent.Sign1.Text
local Text2 = script.Parent.Sign2.Text
local Text3 = script.Parent.Sign3.Text
local Text4 = script.Parent.Sign4.Text

local spinner= script.Parent
local PickNum = 2
spinner.CanCollide = false
spinner.Anchored = true
while true do
    if PickNum == 2 then
        spinner.Transparency = 0
    elseif PickNum == 1 then
        spinner.Transparency = 1
    end     
    wait(120)
    PickNum = 3 - PickNum
    if PickNum == 2 then
        Text1 and Text2 and Text3 and Text4 = 'The current gamemode is: Spinner!'
    else
            Text = 'The current gamemode is: Classic!'
    end
end

The error is the first variable of line 19. Everything else in that line is showing fine. Seems this is only a minor error but I don't know how to fix it, so I'll need help with it. Thank you!

2 answers

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago

You can't define varibales by using var1 = var2 = 'text' or var1 and var2 = 'text' in lua, you need to set each variable:

local Text1 = script.Parent.Sign1.Text
local Text2 = script.Parent.Sign2.Text
local Text3 = script.Parent.Sign3.Text
local Text4 = script.Parent.Sign4.Text

local spinner= script.Parent
local PickNum = 2
spinner.CanCollide = false
spinner.Anchored = true
while true do
    if PickNum == 2 then
        spinner.Transparency = 0
    elseif PickNum == 1 then
        spinner.Transparency = 1
    end     
    wait(120)
    PickNum = 3 - PickNum
    if PickNum == 2 then
        Text1 = 'The current gamemode is: Spinner!'
    Text2 = 'The current gamemode is: Spinner!'
    Text3 = 'The current gamemode is: Spinner!'
    Text4 = 'The current gamemode is: Spinner!'
    else
            Text = 'The current gamemode is: Classic!'
    end
end
Ad
Log in to vote
0
Answered by 4 years ago

Nvm, this question is fixed now.

Answer this question