Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Else/elseif not working?

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

5 comments

0

Is session a variable that's accounted for? Also, you need a wait() in that loop, otherwise it will crash.

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.

0

I simply changed it to a 'while true do' to test further, before it was a wait(5)-that isn't the issue.

0

and yes, my variables are accounted for. i'll edit it with the full script

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.

2 answers

✓ Accepted answer

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.

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

3 comments

1

all you did was unindent it. that does not fix it

0

Yes but it was indented. Which it shouldn't have been.

0

But that wouldn't have accounted for the rest of his script. Indentation rarely causes problems, anyway.

This discussion is preserved as it was. New answers, comments, and votes are closed.