generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Trouble with 'else if'?

Previous Thread :: Next Thread 
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Nov 2015 10:22 AM
elseif, not else if


Also, I really recommend local variables.
Report Abuse
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
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
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
09 Nov 2015 10:29 AM
Darn Forum will not let me post the Output.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Nov 2015 10:34 AM
Message the output to me, if you wish.
Report Abuse
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
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
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
09 Nov 2015 11:42 AM
Workspace.Script:20: 'end' expected (to close 'while' at line 6) near ['eof']
Report Abuse
22ron is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image