Attempt to call a nil value

I’m trying to make the local script find a list in workspace, but I can’t find the best way to do it.


local player=game.Players.LocalPlayer
repeat wait()until player.Character:FindFirstChild("Humanoid")
local humanoid=player.Character.Humanoid
local mouse=player:GetMouse()
local anim=Instance.new("Animation")
anim.AnimationId="http://www.roblox.com/asset/?id=5239221954"
local cities=game.Workspace:GetChildren("area1","area2","area3")
local furniture=cities:GetChildren("item1","item2","item3","item4","item4")
--
local inputservice=game:GetService("UserInputService")
inputservice.InputBegan:connect(function(i,g)
	if i.UserInputType==Enum.UserInputType.Keyboard then
		if i.KeyCode==Enum.KeyCode.E then
			for _,Asset in pairs(cities:GetChildren(furniture))do
				local Mag=(Asset.Door.Center.Position-game.Players.LocalPlayer.Character.IntPoint.Position).magnitude
				if Mag<=Asset.Door.Range.Value then
					Asset.Door.Event:FireServer()
					local playAnim=humanoid:LoadAnimation(anim)
					playAnim:Play()
					break
				end
			end
		end
	end
	end)



--problem 
[Players.RanTos32.Backpack.interact:8: attempt to call a nil value](rbxopenscript://www.dummy.com/dummy?scriptGuid=%7B980833F2-8DAA-4200-B703-DF2DA519D412%7D&gst=2#8)

Comment not solution:
You shoud add ```lua to the start of your message and close it up with another three grave accents to use the Lua format so it is easier to read. Also four spaces is equivalent to a tab key.

1 Like

GetChildren can’t be used like that. It takes no arguments.

You can either use GetChildren and use a for loop to get everything matching those names, or use CollectionService (what I would recommend.)

2 Likes