Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempt to index nil with number someone help?

Asked by 2 years ago
Edited 2 years ago

I looked on the Roblox dev forum, but I couldn't find anything that could help me with this error. Also I am new with this coding thing so I got a you tube video to help me. Here's the code:

          local handle =                         game.ReplicatedStorage:WaitForChild("ToolModels"):FindFirstChild(availableTools[i] 
          [1].."Handle"):Clone() -- Where I got the error
           handle.Parent = itemViewport

1 answer

Log in to vote
0
Answered by 2 years ago

That error means that you're trying to get a value from a table that doesn't exist, make sure you define "availableTools" somewhere in your script - check spelling and capitalisation.

You can make things easier to debug by splitting everything up a bit:

local storage = game.GetService("ReplicatedSotrage")
local models = storage.WaitForChild("ToolModels")

local string = toString(availableTools[1] ... "Handle") --error will come here if you don't define "availableTools" somewhere
-- Check how to concatenate and how to convert to string, I've not done this in a while lol

local handle = models.FindFirstChild(string):Clone()

handle.Parent = itemViewporr
0
how do you define things in roblox studio? Altbotnot 9 — 2y
Ad

Answer this question