I'm currently trying to make a script that will cause you to catch fire when you touch a part but there's a blue line beneath fire.
function lightonfire(part) print("Going to light this part on fire:") print(part.Name) fire = Instance.new("Fire") fire.parent = part end
The first time fire is mentioned in the 5th line of code is the word that has the blue squiggly line beneath it.
The blue squiggly line is appearing because you are using a global variable where it is not needed. Put the local
keyword and you should be fine:
function lightonfire(part) print("Going to light this part on fire:") print(part.Name) local fire = Instance.new("Fire") fire.parent = part end
Remember, a blue squiggly line means a warning and not an error. A warning will not stop the code from running. Think of it as a suggestion on what you should do as a best practice.
A global variable is a variable that can be accessed from all parts of the script. A local variable is a variable that can be accessed in the scope it was defined in.
A scope is a region of a script where a variable can be accessed.
Consider the example here:
local c = 5 if c == 5 then local a = 4 global = 3 end print(c) --prints 5 print(a) --prints nil print(global) --prints 3
The reason a prints nil is because the variable defined in the if statement is local and can only be accessed inside the if statement (which is the scope).
The reason c prints 5 is because it was defined outside and thus its scope encompasses the entire script.
The global variable prints 3 and not nil because it is a global variable and is not limited to the scope it was defined in. Notice that a global variable does not have a local
keyword in the declaration.