|
| 14 Feb 2016 07:45 PM |
I have a command script in which I type my command into a textbox, then execute it by clicking a textbutton. The problem is. I have two commands: e.g. if "God" then stuff elseif "Human" then stuff end
The problem is, The if works, except elseif. Any solution? |
|
|
| Report Abuse |
|
|
Romul
|
  |
| Joined: 08 Mar 2009 |
| Total Posts: 597 |
|
|
| 14 Feb 2016 08:29 PM |
When your command is running, does it hit on a God? Elseif works only if the first thing it hits is not God. If the God statement is found then it skips the elseif as it isn't necessary. You would need to seperate them.
if "God" then blah blah end
if "Human" then blah blah end
|
|
|
| Report Abuse |
|
|
|
| 14 Feb 2016 08:30 PM |
| I tried that already, didn't work |
|
|
| Report Abuse |
|
|
Romul
|
  |
| Joined: 08 Mar 2009 |
| Total Posts: 597 |
|
|
| 14 Feb 2016 08:32 PM |
| That's odd. Could you please post the error code it is giving? If ingame that would be through clicking F9 and checking the Dev Console, or the Output in the Studio. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 08:21 AM |
| It doesn't output an error code. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 08:42 AM |
post more of the script
#Strikin' |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 08:59 AM |
The problem is that you are checking if the string exists, and we already know it exists. You need to compare the string to something.
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 09:22 AM |
Here is my script:
local cmdbar = script.Parent.Parent.Command local main = script.Parent
script.Parent.MouseButton1Click:connect(function() if cmdbar.Text == "god" then script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.MaxHealth = script.Parent.GodHealthValue print(script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.MaxHealth) elseif cmdbar.Text == "human" then script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.MaxHealth = 100 print(script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.MaxHealth) end end)
Output: 10000 100
When I wrote god in my textbox that is what it executes. Changes to 10000 for a millisecond. then returns to 100. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 09:29 AM |
For a more better understanding:
Here is a link to the temporary model. http://www.roblox.com/item.aspx?id=364657223 |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 11:12 AM |
nvm, fixed it. Here: --Made by RaulChaser local cmdbar = script.Parent.Parent.Command local main = script.Parent local human = script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid local humanac = false local godac = false local eelac = false
script.Parent.MouseButton1Click:connect(function() if cmdbar.Text == "god" then godac = true print("Activated") elseif cmdbar.Text == "human" then humanac = true print("Activated") elseif cmdbar.Text == "eel" then eelac = true print("Activated") else print("Unknown Command") cmdbar.Text = "Unknown Command" wait(1.5) cmdbar.Text = "Enter Command" end if godac == true then human.MaxHealth = 10000 print(human.MaxHealth) godac = false end if humanac == true then human.MaxHealth = 100 print(human.MaxHealth) humanac = false end if eelac == true then if script.Parent.Parent.Parent["Extension List"].Visible == false then script.Parent.Parent.Parent["Extension List"].Visible = true elseif script.Parent.Parent.Parent["Extension List"].Visible == true then script.Parent.Parent.Parent["Extension List"].Visible = false end end end) |
|
|
| Report Abuse |
|
|