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 » Scripting Helpers
Home Search
 

Re: Really stupid problem...

Previous Thread :: Next Thread 
800imawesome is not online. 800imawesome
Joined: 28 Mar 2010
Total Posts: 2520
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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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
800imawesome is not online. 800imawesome
Joined: 28 Mar 2010
Total Posts: 2520
24 Mar 2013 09:01 PM
Oh yeah, I had the other end, I just forgot it when copying it down.
Report Abuse
adark is not online. 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
800imawesome is not online. 800imawesome
Joined: 28 Mar 2010
Total Posts: 2520
24 Mar 2013 09:05 PM
Thanks a lot to both aof you, I got it working.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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