|
| 24 Mar 2013 08:53 PM |
*NOTE: I'm new to scripting, so sorry if this fails*
I can't get this script to work, can anybody help fix it?
function Fail(1, 1) 1 + 1 = Hi if Hi >= 12 then print("Yes") else print("No") wait(1) end
Fail(1, 1)
It has correct syntex, but it won't show excessive spaces on here. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2013 08:58 PM |
The parameters should be strings, so you can store what they put in as the arguments:
function Fail(Num1, Num2) Hi = Num1 + Num2 if Hi >= 12 then print("Yes") else print("No") wait(1) end Fail(1, 1)
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2013 08:58 PM |
You also need another end.
function Fail(Num1, Num2) Hi = Num1 + Num2 if Hi >= 12 then print("Yes") else print("No") wait(1) end end Fail(1, 1)
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2013 09:01 PM |
| Oh yeah, I had the other end, I just forgot it when copying it down. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Mar 2013 09:01 PM |
You're on the right track. I went through line by line and modified your script:
function Fail(a, b) --[[I'm assuming you want to have these be parameters. Parameters are variables used when calling a functions to modify what the function outputs. They follow the rules of naming variables, so they have to be unique, and can't start with numbers.]] Hi = a + b --[[Close, but you declare a variable like this: variable = content. You did it backwards.]] if Hi >= 12 then --[[Correct. Remember that two equal signs are used for comparison, not just one: ==]] print("Yes") --[[Correct]] else --[[Correct]] print("No") --[[Correct]] --[[There is no need for a wait(), especially since you only put it inside the 'else' side of the if statement.]] end end --[[Your first end only close the if statement, you need another to close a functions. The following keywords require an end: function, if, and do. Elseif and else do not require their own ends, but they do require an if.]]
Fail(1, 1) --[[Will print the string, "No". In your function, the parameter a takes the value of the first number here, a 1, and the parameter b takes the second value, also 1.]]
|
|
|
| Report Abuse |
|
|
|
| 24 Mar 2013 09:05 PM |
| Thanks a lot to both aof you, I got it working. |
|
|
| Report Abuse |
|
|