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: If statement not fully working

Previous Thread :: Next Thread 
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
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 is not online. 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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
14 Feb 2016 08:30 PM
I tried that already, didn't work
Report Abuse
Romul is not online. 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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
16 Feb 2016 08:21 AM
It doesn't output an error code.
Report Abuse
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
16 Feb 2016 08:42 AM
post more of the script




#Strikin'
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
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
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