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

Why is there a red line at the bottom of this script?

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

7 comments

0

Just hover over the word that the line is under

0

it should tell you

0

I cant understand it it says "Expected 'end' ('to close 'then' at line 18), got

0

There should be 2 ends

0

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!

0

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.

0

I put the code into a code block.

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.