Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this attempt to index a nil value?

I am trying to make a script, that get's every StringValue in game.ServerStorage.Testing, but every time I run the script it tell's me this error. attempt to index field 'Parent' (a nil value) Anyone have a idea on how I can fix it?

a = game.ServerStorage.Testing:GetChildren()

for v = 1,#a do     
    local t = script.Parent.Parent.Parent.Script.temp:Clone()
    t.Name = v.Name
    t.NameT.Text = v.Name
    t.Position = UDim2.new(0,10,0,(t*35))   
    t.Parent = script.Parent.Parent.Parent
end

6 comments

0

Is in in a LocalScript?

0

No, is it supposed to be?

0

Which line is it?

0

The 4th, local t = script.Parent.Parent.Parent.Script.temp:Clone()

0

change the v.Name to a[v] and pls tell the parent of ur script

0

What

1 answer

✓ Accepted answer

Hi, ISellCows. The problem with your script is that you are trying to get the name of v (a number value), Instead of getting the name of a[v] (the object)

If you're too lazy to read what I said above, I wrote you a more efficient version.

a = game.ServerStorage.Testing:GetChildren()

for _,Object in pairs(a) do     
    local t = script.Parent.Parent.Parent.Script.temp:Clone()
    t.Name = Object.Name
    t.NameT.Text = Object.Name
    t.Position = UDim2.new(0,10,0,(t*35))   
    t.Parent = script.Parent.Parent.Parent
end

This discussion is preserved as it was. New answers, comments, and votes are closed.