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

Else/elseif not working?

Asked by
unmiss 337 Moderation Voter
9 years ago
local ljustice = script.Parent:WaitForChild("JusticeS")
local lprosecutor = script.Parent:WaitForChild("ProsecutorS")
local ldefender = script.Parent:WaitForChild("DefenderS")
local lcharges = script.Parent:WaitForChild("ChargesS")
local llevel = script.Parent:WaitForChild("LevelS")
local CurrentStepS = script.Parent:WaitForChild("CurrentStepS")
local lISS = script.Parent:WaitForChild("ISS")

local RS = game.ReplicatedStorage
local Defender = RS.CurrentDefender -- stringvalue
local Justice = RS.CurrentJustice -- stringvalue
local Charges = RS.CurrentCharges -- stringvalue
local Prosecutor = RS.CurrentProsecutor -- stringvalue
local Level = RS.CurrentLevel -- stringvalue
local Step = RS.CurrentStep -- stringvalue
local session = RS.isInSession -- boolean

while wait(3.458) do

    ljustice.Text = Justice.Value
    lprosecutor.Text = Prosecutor.Value
    ldefender.Text = Defender.Value
    lcharges.Text = Charges.Value
    llevel.Text = Level.Value
    CurrentStepS.Text = Step.Value

    if session.Value == false then
        lISS.Text = "No"
    elseif session.Value == true then
        lISS.Text = "Yes"
    end
end



everything at the else line and after doesn't do anything

0
Is session a variable that's accounted for? Also, you need a wait() in that loop, otherwise it will crash. Spongocardo 1991 — 9y
0
Isn't you game crashing when this runs? It should, since you have an eternal loop with no delays. If it doesn't, there's probably some sort of error. Please post any output you have. Perci1 4988 — 9y
0
I simply changed it to a 'while true do' to test further, before it was a wait(5)-that isn't the issue. unmiss 337 — 9y
0
and yes, my variables are accounted for. i'll edit it with the full script unmiss 337 — 9y
0
If no errors are being thrown in the output, it usually means one of your variables that has WaitForChild in it is continuing to wait for something that isn't there. Try directly referencing the object instead of using WaitForChild. If that errors, check that the parenting is correct. Spongocardo 1991 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

If no errors are being thrown in the output, it usually means one of your variables that has WaitForChild in it is continuing to wait for something that isn't there.

Try directly referencing the object instead of using WaitForChild. If that errors, check that the parenting is correct.

Ad
Log in to vote
-1
Answered by 9 years ago

Look, here is what it should be like.

while true do

    ljustice.Text = Justice.Value
    lprosecutor.Text = Prosecutor.Value
    ldefender.Text = Defender.Value
    lcharges.Text = Charges.Value
    llevel.Text = Level.Value
    CurrentStepS.Text = Step.Value

    if session.Value == false then
        lISS.Text = "No"
        lISS.TextColor = Color3.new(255,0,0) -- doesn't change the color
    else -- it does not change to Yes if 'session.Value == true'
        lISS.Text = "Yes"
        lISS.TextColor = Color3.new(0,255,0) -- doesn't change the color
    end
end
1
all you did was unindent it. that does not fix it unmiss 337 — 9y
0
Yes but it was indented. Which it shouldn't have been. jamesbiggsbot 0 — 9y
0
But that wouldn't have accounted for the rest of his script. Indentation rarely causes problems, anyway. Spongocardo 1991 — 9y

Answer this question