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: How do you check if something Exists? *confused* :)

Previous Thread :: Next Thread 
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:04 PM
Hi All,

I was wonder how you would check if a brick or object Exists,

In my case a 'Fire'.

Any Help,

Thanks,

J92.
Report Abuse
harutsedo is not online. harutsedo
Joined: 11 Oct 2009
Total Posts: 5150
04 Aug 2010 02:05 PM
Simple.

if game.Workspace:FindFirstChild("Fire") then
print"It exists!"
end
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:08 PM
I've jus tried that but doesnt work =S


if (string.sub(msg,1,5) == "norm/") then
p = string.sub(msg,6)
c = game.Players:findFirstChild(p)
t = c.Character:findFirstChild("Head")
if t:findFirstChild("Fire") then
t:findFirstChild("Fire"):remove()
end
end
Report Abuse
Kaleb12 is not online. Kaleb12
Joined: 09 Jun 2008
Total Posts: 10976
04 Aug 2010 02:13 PM
Dunno if this will work, but

h = game.Workspace.Kaleb12
if h == nil do
print ("Kaleb12 isn't here")
else
print ("Kaleb12 is here!")
Report Abuse
CrazyTom721 is not online. CrazyTom721
Joined: 03 Nov 2008
Total Posts: 2054
04 Aug 2010 02:14 PM
if (string.sub(msg,1,5) == "norm/") then
p = string.sub(msg,6)
c = game.Players:findFirstChild(p)
if c ~= nil then
t = c.Character:findFirstChild("Head")
if t ~= nil then
if t:findFirstChild("Fire") then
t:findFirstChild("Fire"):remove()
end
end
end
end


try that. see if it works. :)
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:15 PM
@Kaleb: Nope =\

@Tom: Ill give it a try :)
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:19 PM
Nope =\

If this is any help.

if (string.sub(msg,1,5) == "fire/") then
p = string.sub(msg,6)
c = game.Players:findFirstChild(p)
t = c.Character:findFirstChild("Head")
f = Instance.new("Fire")
f.Name = "Fire"
f.Parent = t
f.Heat = 9
f.Color = BrickColor.new(Color3.new(255, 127, 0))
f.SecondaryColor = BrickColor.new(Color3.new(255, 0, 0))
f.Size = 5
end
__________________
Report Abuse
Kaleb12 is not online. Kaleb12
Joined: 09 Jun 2008
Total Posts: 10976
04 Aug 2010 02:21 PM
My memory fails me, what does string.sub do again?
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:23 PM
the first if statement

gets the fire/ bit then the other bit..
p = string.sub(msg,6)

gets the rest AFTER the fire/ bit
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
04 Aug 2010 02:23 PM
string.sub(str, n. x)

Returns as a string, the characters between the nth and xth character of str.
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
04 Aug 2010 02:23 PM
The one . of mine should be a ,
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:24 PM
anyways back to my bit :)

I still cant make it remove the fire =\
Report Abuse
Kaleb12 is not online. Kaleb12
Joined: 09 Jun 2008
Total Posts: 10976
04 Aug 2010 02:27 PM
I'm to much of a newb to work this into your script, so I'll just post how I *think* you would check for fire. Sorry if I'm not helping.

h = game.Workspace.BrickWithFire.Fire
if h == nil do
print ("There is no fire")
else do
print ("There is fire")

Hardly different from my othe script, so I doubt it. I've never used "else" before so I could be using it wrong.
Report Abuse
Kaleb12 is not online. Kaleb12
Joined: 09 Jun 2008
Total Posts: 10976
04 Aug 2010 02:27 PM
I'm to much of a newb to work this into your script, so I'll just post how I *think* you would check for fire. Sorry if I'm not helping.

h = game.Workspace.BrickWithFire.Fire
if h == nil do
print ("There is no fire")
else do
print ("There is fire")

Hardly different from my othe script, so I doubt it. I've never used "else" before so I could be using it wrong.

Floods are evily annoying.
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:32 PM
Just trying now =\
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:33 PM
This is proberlly something really simple =\

That didnt work :S
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
04 Aug 2010 02:34 PM
if (string.sub(msg,1,5) == "fire/") then
p = string.sub(msg,6)
if c ~= nil then
c = game.Players:findFirstChild(p)
t = c.Character:findFirstChild("Head")
f = Instance.new("Fire")
f.Name = "Fire"
f.Parent = t
f.Heat = 9
f.Color = BrickColor.new(Color3.new(255, 127, 0))
f.SecondaryColor = BrickColor.new(Color3.new(255, 0, 0))
f.Size = 5
end
end

if string.sub(msg, 1, 7) == "nofire/" then
p = string.sub(msg,6)
c = game.Players:findFirstChild(p)
if c ~= nil then
t = c.Character.Head
if t:findFirstChild("Fire") ~= nil then
t.Fire:remove()
end
end
end
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
04 Aug 2010 02:38 PM
Kaleb, are you sure if [statement] do works? I'm sure it only works with 'then'.

Anyway, are you sure it is checking if there is fire? Maybe there's another, different problem. I've no idea what that would be though. Does the first command set you on fire to start with?
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
04 Aug 2010 02:40 PM
Also, Kaleb, if something does not exist, it cannot be indexed, so that would error if Fire did not exist.
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:41 PM
Ill give it a go. :D
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
04 Aug 2010 02:44 PM
Blab, you wrote this :-

'if c ~= nil then'

In the first part of the script, but c did not exist before then, so that will never work.
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:44 PM
The fire one works, but the nofire/ one doesnt work :S

GRR
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
04 Aug 2010 02:45 PM
Whoops. And Jamie I think you're testing wrong.
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:45 PM
oh yeah, i changed that bit around so the c was there before :P
Report Abuse
Jamie2992 is not online. Jamie2992
Joined: 01 Aug 2010
Total Posts: 416
04 Aug 2010 02:46 PM
I am? O.O

_FLOOOOOOOOOOOOOOOOOOOD_
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