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: attempt to call method 'FindFirstChild' (a nil value)

Previous Thread :: Next Thread 
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
28 Jun 2015 07:39 AM
--Line:
function stacktargetshop(name)
local Box = ChildShopStore:FindFirstChild(Name) --<<
print("G")
end

--Call:
mouse.Button1Down:connect(function()
local targ = mouse.Target
if targ.Parent.Name == "ShopBrickGrouping" then
print(targ.Name)
stacktargetshop(targ.Name)
end
end)

?
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
28 Jun 2015 07:42 AM
There is so many errors...

First, you are not passing a created variable through local Box = ChildShopStore:FindFirstChild(). You have never defined ChildShopStore and you have failed to grab the mouse to use it. Also, your methods for checking will error.

if(targ.Parent)then
if(targ.Parent.Name == "ShopBrickGrouping")then
-- correct
end
end
Report Abuse
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
28 Jun 2015 07:50 AM
What kind of incompetent fool do you think I am?
This is the whole script, I omitted the unnecessary things:


local player = game.Players.LocalPlayer
local queen = script.Parent.ScreenGui
local mouse = player:GetMouse()
local workspace = game.Workspace
local shoplist = workspace.ShopBrickGrouping
local gui = script.Parent.ScreenGui
local ShopItems = game.ServerStorage.Shopitems
local ChildItems = ShopItems:GetChildren()
local ShopStore = game.ServerStorage.Shops
local ChildShopStore = ShopStore:GetChildren()
local ItemPaddingY = 55
local MouseX = 0
local MouseY = 0

local Station
local Wallet
local Inventory
local shopGUIsopen = false


local shops = {
[shoplist.Blue] = 0,
[shoplist.Red] = 0,
[shoplist.Green] = 0,
[shoplist.Pink] = 0
}

function stacktargetshop(name)
local Box = ChildShopStore:FindFirstChild(name)
local Spec = Box.Species.Value
local Folder = ChildItems:FindFirstChild(Spec)
for i, v in pairs(Folder:GetChildren()) do
local b = v:Clone()
b.Parent = queen.Shop.Supply
b.Position.X.Offset = ItemPaddingY
ItemPaddingY = ItemPaddingY + 55
end

end

mouse.Button1Down:connect(function()
local targ = mouse.Target
if targ.Parent.Name == "ShopBrickGrouping" then
print(targ.Name)
stacktargetshop(targ.Name)
end
end)

Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
28 Jun 2015 07:52 AM
why wouldn't this work...
a table is not an instance

local ChildShopStore = ShopStore:GetChildren()
local Box = ChildShopStore:FindFirstChild(name)
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
28 Jun 2015 07:56 AM
You have failed to realize the importance of having everything shown for us to look at.

local shoplist = workspace.ShopBrickGrouping
local ShopItems = game.ServerStorage.Shopitems

Should be

local shoplist = workspace:WaitForChild("ShopBrickGrouping")
local Storage = game:GetService("ServerStorage")
local ShopItems = Storage:WaitForChild("Shopitems")
local ShopStore = Storage:WaitForChild("Shops")

...

local ChildItems = ShopItems:GetChildren()
local ChildShopStore = ShopStore:GetChildren()

This should be called at the time of it needing to get children. Doing this at the beginning will break you using this, as it is just a reference. Plus, the children may not be ready to grab and give false results.

...

if targ.Parent.Name == "ShopBrickGrouping" then

Should be

if targ.Parent then
if targ.Parent.Name == "ShopBrickGrouping" then

end
end
Report Abuse
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
28 Jun 2015 08:03 AM
Thanks, got it to work.
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