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

Previous Thread :: Next Thread 
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:00 PM
How to make it like

if there is c then it will do something

c = hit.Parent:FindFirstChild("Head")
if c then
c:Remove()

BUT THEN

even if it doesn't have c it will go back to something like

script.Parent.Transparency=1

so what I am trying to say is

if it has c it does something but after doing it continues to run the script
but even if it doesn't have c then it still runs the part after the if c then

Because if there is no c and it tried to remove then there wont be a c and script crashes

PLEASE HELP



TLDR =
if it has c it does something but after doing it continues to run the script
but even if it doesn't have c then it still runs the part after the if c then


whistles
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:02 PM
if c then
--part that requires c
end
--part that doesn't require c

http://wiki.roblox.com/index.php?title=Intro_to_Scripting


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
28 Nov 2016 08:02 PM
um

function script()
if c then
-- do stuff specific to if c
end
-- stuff to do regardless of c
end


i'm not any more should not the panda and?
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:04 PM
If I do that wont that mean the script stops running if there is a c and wont run the rest?


whistles
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:05 PM
No.

http://wiki.roblox.com/index.php?title=Intro_to_Scripting

Code runs in blocks


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
28 Nov 2016 08:05 PM
no it wont because it's not in the same parts

look

local c = false

if c then
print("wow it is c")
end
print("regardless of c")

--> regardless of c

local c = true
if c then
print("wow it is c")
end
print("regardless of c")

--> wow it is c
--> regardless of c


i'm not any more should not the panda and?
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:06 PM
after the if c part would I do else after it or no


whistles
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:07 PM
else means like the opposite.


if c then
print('c is a thing')
else
print('c is not a thing')
end
print('Im here if c is, or is not')


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:07 PM
http://wiki.roblox.com/index.php?title=Conditional_statement


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:08 PM
So this would worK? # # ################################# t = hit.Parent:FindFirstChild("Torso") function onTouched(hit) if c then c.Transparency=1 end t:Remove() end script.Parent.Touched:Connect(onTouched) whistles
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:11 PM
Why are you asking "would this work"

Try it in studio


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:11 PM
Would this work


if c then --Sees if there is a c
c:Remove() --Removes c if there is a c
end
t:Remove() --t is removed if there is c or not a c
if b then
b:Remove() --if there is a b it is removed
end
z:Remove() --removes z
end --script stops here


would this work and not stop till end?



whistles
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:12 PM
Assuming that last end actually goes to something, yes


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
28 Nov 2016 08:13 PM
yes


i'm not any more should not the panda and?
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
28 Nov 2016 08:13 PM
ok thanks guys


whistles
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
28 Nov 2016 08:14 PM
no problem

I suggest you try and learn coding basics though, this is something very simple


i'm not any more should not the panda and?
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
28 Nov 2016 08:15 PM
Check out the links I posted.

I didn't post them for my benefit


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
28 Nov 2016 08:58 PM
Actually, if you remove the head i believe the player dies. I may be mistaken but that might be your issue...
Report Abuse
CosmicPigeon is not online. CosmicPigeon
Joined: 14 Oct 2012
Total Posts: 5978
29 Nov 2016 04:56 PM
@Xstarlight
That wasn't the script that was just an example


whistles
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