part = game.Workspace.Part
while true do
local Newpos = pos
wait(5)
part.BrickColor = BrickColor.new("Maroon")
pos = math.random(1,4) -- picks a number for pos
if pos == 1 then --this makes decisions to where it teleports
part.Position = game.Workspace.Start.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos == 2 then
part.Position = game.Workspace.Start2.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos == 3 then
part.Position = game.Workspace.Start3.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos ==4 then
part.Position = game.Workspace.Start4.Position
part.BrickColor = BrickColor.new("Persimmon")
end
--end is underlined with red I cant figure out why and it is breaking my script
COMMUNITY QUESTION
Why is there a red line at the bottom of this script?
1 answer
You forgot to put another end at the end xD Here's the fixed code ;)
part = game.Workspace.Part
while true do
local Newpos = pos
wait(5)
part.BrickColor = BrickColor.new("Maroon")
pos = math.random(1,4)
if pos == 1 then
part.Position = game.Workspace.Start.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos == 2 then
part.Position = game.Workspace.Start2.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos == 3 then
part.Position = game.Workspace.Start3.Position
part.BrickColor = BrickColor.new("Persimmon")
elseif pos == 4 then
part.Position = game.Workspace.Start4.Position
part.BrickColor = BrickColor.new("Persimmon")
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Just hover over the word that the line is under
it should tell you
I cant understand it it says "Expected 'end' ('to close 'then' at line 18), got
There should be 2 ends
You forgot to close off the "then" at line 18. When it shows "Expected 'end'" (Happens a lot) then just add another end. Good luck!
You should add another "end" to the script. At line 2 you start a "while true do" that you end at line 19 (last line), but at line 7 you start a "if" that you never end.
I put the code into a code block.