Error on end) part

I made traffic lights and they work fine but my only issue is the cross button.

here’s the traffic lights

here’s the cross and don’t cross signs…

and here’s the button

BTW this is a game I’m working on but I can’t tell you what it is if you ask.

  1. What is the issue? when you press the button for when you want to cross the streets, there’s an error that pops up as soon as you test play the game.

  2. What solutions have you tried so far? I tried looking on the other forms but didn’t help at all so this is why I’m writing this

	if script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == true then
		print("you may corss the streets the light is red")
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		elseif
		script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == false then
		print("you may not cross the street as the light is not red")
		elseif
		script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == true then
		print("you may corss the streets the light is red")
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go.BrickColor = BrickColor.new("Sea green")
		elseif
		script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == false then
		print("you may not cross the street as the light is not red")
	end
end
end)--my error is here this one line of code

Based on your error, I’m assuming you need to move the closing parenthesis up one end.

I’m no pro, but it looks like you only have 1 ‘if’ statement, with a bunch of 'elseif’s inside it. I’d suggest removing the last 2 ‘end’ statements.
You also shouldn’t need a bracket at the end of this, unless it’s this is only part of the entire script and you have a function somewhere above the first line you posted.

that doesn’t really work as it underlines the last end part in red, even adding another end to it, it seems to be the 3th one giving off the error

You need to remove an end.

Should look something like this:

clickDetector.MouseClick:Connect(function()
    if foo then
        return bar
    elseif bar then
        return foo
    end
end)
1 Like

get rid of the “end” at the end of the script and unindent the whole thing by highlighting it all and pressing ctrl+{

I think that might have fixed it, all I did was remove the 3th end and then tested it and I think it works but I don’t know yet still messing around with it before I put solution.

oops i didnt see that there was two ends you dont need them basically just copy and paste this i have removed them and unindeted the code

if script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == true then
	print("you may corss the streets the light is red")
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
	wait(0.5)
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
	wait(0.5)
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
elseif
	script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == false then
	print("you may not cross the street as the light is not red")
elseif
	script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == true then
	print("you may corss the streets the light is red")
	script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
	wait(0.5)
	script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
	wait(0.5)
	script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
	wait(0.5)
	script.Parent.Parent.Side1.Go.BrickColor = BrickColor.new("Sea green")
elseif
	script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == false then
	print("you may not cross the street as the light is not red")
end

No, you need to close the function as well.

	if script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == true then
		print("you may corss the streets the light is red")
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go2.BrickColor = BrickColor.new("Sea green")
		elseif
		script.Parent.Parent.Parent.RYG_Light.Red.BoolValue.Value == false then
		print("you may not cross the street as the light is not red")
		elseif
		script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == true then
		print("you may corss the streets the light is red")
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Sea green")
		wait(0.5)
		script.Parent.Parent.Side1.Go1.BrickColor = BrickColor.new("Black")
		wait(0.5)
		script.Parent.Parent.Side1.Go.BrickColor = BrickColor.new("Sea green")
		elseif
		script.Parent.Parent.Parent.RYG_Light1.Red.BoolValue.Value == false then
		print("you may not cross the street as the light is not red")
	end
end)--my error is here this one line of code

^ this will work

cc @cookpie416

are these blocks within a function? if so then yes @Sterpant is correct.

ya that what I had I tried it and it worked but still testing it to make sure it works for real

Maybe try removing or adding 'end’s?

no it works fine, it’s just I have something to fix before saying it works.