|
| 09 Nov 2015 10:22 AM |
Hello I'm fairly new to scripting, and I have run into an issue that I don't know how to resolve. Every time I add 'else if' to Line 15, Line 6 is highlighted in yellow with a Arrow by it, and my server is forced to pause until I disable my script.
What do I need to know to get around this problem?
----------------------------------- Line# : Script Content ----------------------------------- 1 : W = Workspace 2 : S = W.Script 3 : C = W.Count 4 : M = 0 5 : 6 : while S.Archivable == true do 7 : print ('Count is', C.Value) 8 : 9 : 10 : if C.Value < 250 then 12 : M = M + 1 13 : C.Value = M 14 : 15 : else if C.Value > 750 then 16 : M = M - 1 17 : C.Value = M 18 : 19 : wait() end end end
------------------------------ |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 10:22 AM |
elseif, not else if
Also, I really recommend local variables. |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 10:28 AM |
K,I changed 'else if' to 'elseif' (Thank you for that) But now my Input Window is giving me; --------------------------------------
-------------------------------------- And It still will not un-pause.
Also, I would love to use local variables, but I have no idea how they work. What is the difference between local and not?
|
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 10:29 AM |
| Darn Forum will not let me post the Output. |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 10:33 AM |
Local variables only work in the scope they were declared in.
-- This is the default scope
for blah = 1, 10 do -- This is a new scope end
function hi() -- This is a new scope end
while a < 5 do -- This is a new scope end
do -- This is a new scope function hi() -- This is a new scope inside of a new scope end end
Local variables can be accessed by scopes within the current scope, but not by parent scopes.
-- This is the parent scope local A = 5 -- This can be accessed by any scope inside of the current one. do -- This is a scope within the parent scope local B = 5 -- This can't be accessed outside of the do-end. end
|
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 10:34 AM |
| Message the output to me, if you wish. |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 11:41 AM |
let me see if I can reword it:
Error : (20,1) Expected 'end' (to close 'do' at line 6),got {eof} |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2015 11:42 AM |
| Workspace.Script:20: 'end' expected (to close 'while' at line 6) near ['eof'] |
|
|
| Report Abuse |
|
|
22ron
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 279 |
|
|
| 09 Nov 2015 12:08 PM |
W = Workspace S = W.Script C = W.Count M = 0 while S.Archivable == true do print ('Count is', C.Value)
if C.Value < 250 then M = M + 1 C.Value = M
elseif C.Value > 750 then M = M - 1 C.Value = M
wait() end end |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 09 Nov 2015 01:55 PM |
In C, it's 'else if'. In Lua, it's one word 'elseif'.
Using 'while true do' is bad practice. If you're creating a while loop, for security ALWAYS do 'while wait() do', or if you have a triggering variable, 'while true and wait() do',
And there are some easy notes.
If your error is 'expected "end" to close function -blank- at [eof]' or anything similar, you're missing an end. Add one on the end. |
|
|
| Report Abuse |
|
|