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: Attempt to call "findFirstChild"

Previous Thread :: Next Thread 
ThrashingThunder is not online. ThrashingThunder
Joined: 03 Oct 2011
Total Posts: 2388
14 Feb 2014 06:28 PM
wait()
players = game.Players:GetChildren()
for i = 1,#players do
game.Lighting["Knife"]:Clone().Parent = players[i].Backpack
end

LongKnife = players:findFirstChild("LongKnife")
if LongKnife ~=nil then
game.Lighting["LongKnife"]:Clone().Parent = players.Backpack
end

Never got this error before.
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
14 Feb 2014 06:31 PM
for i,v in pairs(game.Players:GetPlayers()) do
game.Lighting.Knife:Clone().Parent = v:WaitForChild("Backpack")
if not v.Backpack:FindFirstChild("LongKnife") then
game.Lighting.LongKnife:Clone().Parent = v.Backpack
end
end

Why would you give another one to them if it's already there? ~= means not, so ~= nil means it does exist.
Report Abuse
xPoloBear is not online. xPoloBear
Joined: 10 Oct 2011
Total Posts: 202
14 Feb 2014 06:31 PM
Why is there a wait() ??


Fixed script:

players = game.Players:GetChildren()
for i = 1,#players do
game.Lighting["Knife"]:Clone().Parent = players[i].Backpack
end

LongKnife = players:findFirstChild("LongKnife")
if not LongKnife then
game.Lighting["LongKnife"]:Clone().Parent = players[i].Backpack
end
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
14 Feb 2014 06:32 PM
Polo I already handled it, and I did it better.
Report Abuse
ThrashingThunder is not online. ThrashingThunder
Joined: 03 Oct 2011
Total Posts: 2388
14 Feb 2014 06:32 PM
Thanks
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