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: FindFirstChild() not working in ChildAdded loop

Previous Thread :: Next Thread 
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 05:45 PM
Title says all. Lemme give an example of what's happening:

here's a segment of my code:

if child.ClassName == "Part" then
if child:FindFirstChild("NoGrav") == nil then

The first line works, but it ignores the second line regardless of whether the object has "NoGrav" or not.


Can someone help please? Thanks!
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
21 Apr 2014 05:46 PM
It's :findFirstChild()
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
21 Apr 2014 05:47 PM
~= nil?
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 05:48 PM
@you

I've always used a capital, and it's always worked until now.

@vlek

I want it to only proceed if it DOESN'T have NoGrav inside it.
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
21 Apr 2014 05:51 PM
Instead of putting in NoGrav and see if it works
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
21 Apr 2014 05:52 PM
No space behind it?
Script works fine.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 05:52 PM
@ace

Wat?
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 05:53 PM
@vlek

It works fine in solo mode, but it breaks in servers.
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
21 Apr 2014 05:56 PM
Ummm try local script
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 05:57 PM
*grown*

That's impossible! The way I programmed the script won't allow it to work from any player!
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:00 PM
URGH! I HAVE THE PATIENCE OF A SQUIRREL! HALP MAH PLS!!11!!!1
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
21 Apr 2014 06:01 PM
We canp u any more further with this info. :/
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:02 PM
...

Please just help me. I spent hours writing an anti-gravity script and can't finish it with this major setback!
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
21 Apr 2014 06:03 PM
Full script please
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:03 PM
--Scripted by tinarg

Workspace.ChildAdded:connect(function(child)

if child.ClassName == "Model" then

for _, v in pairs(child:GetChildren()) do


if v.ClassName == "Part" or v.ClassName == "WedgePart" or v.ClassName == "TrussPart" or v.ClassName == "CornerWedgePart" or v.ClassName == "Seat" or v.ClassName == "VehicleSeat" or v.ClassName == "SkateboardPlatform" then
if v:FindFirstChild("NoGrav") == nil then

local NoGrav = Instance.new("BodyForce")
local FixGrav = script.FixGravity:clone()

FixGrav.Parent = v
FixGrav.Disabled = false

NoGrav.Name = "NoGrav"
NoGrav.force = Vector3.new(0, v:GetMass() * 196.2, 0)
NoGrav.Parent = v
end
end
end
end

if child.ClassName == "Part" then
if child:FindFirstChild("NoGrav") == nil then

local NoGrav = Instance.new("BodyForce")
local FixGrav = script.FixGravity:clone()

FixGrav.Parent = child
FixGrav.Disabled = false


NoGrav.Name = "NoGrav"
NoGrav.force = Vector3.new(0, child:GetMass() * 196.2, 0)
NoGrav.Parent = child

end
end

if child.ClassName == "Hat" then
if child:FindFirstChild("NoGrav") == nil then
local NoGrav = Instance.new("BodyForce")

NoGrav.Name = "NoGrav"
NoGrav.force = Vector3.new(0, child.Handle:GetMass() * 196.2, 0)
NoGrav.Parent = child.Handle
end
end

end)
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:05 PM
Another script, named FixGravity is found inside the script:



local PSize = script.Parent.Size

while true do
wait(0.05)
if script.Parent.Size ~= PSize then
PSize = script.Parent.Size
script.Parent.NoGrav.force = Vector3.new(0, script.Parent:GetMass() * 196.2, 0)
script.Parent.Velocity = Vector3.new(0,0,0)
end
end
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:20 PM
bump
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:33 PM
Guys? Please help me! D:
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:45 PM
PLEASE! ANYONE!
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:50 PM
I'M DESPERATE!
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:53 PM
Anyone?
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 06:58 PM
HALP MAH
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Apr 2014 07:00 PM
PLEASE! ANYONE! I REALLY NEED IT!
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
21 Apr 2014 07:00 PM
Try this

if child:IsA("Part") then
if not child:FindFirstChild("NoGrav") then
Report Abuse
LIETUVA159 is not online. LIETUVA159
Joined: 17 Aug 2008
Total Posts: 740
21 Apr 2014 07:02 PM
if child.ClassName == "Part" and child:FindFirstChild("NoGrav") == nil then
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