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

Why does this attempt to index a nil value?

Asked by 9 years ago

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

0
Is in in a LocalScript? TheDarkOrganism 173 — 9y
0
No, is it supposed to be? ISellCows 2 — 9y
0
Which line is it? Shawnyg 4330 — 9y
0
The 4th, local t = script.Parent.Parent.Parent.Script.temp:Clone() ISellCows 2 — 9y
View all comments (2 more)
0
change the v.Name to a[v] and pls tell the parent of ur script marcoantoniosantos3 200 — 9y
0
What ISellCows 2 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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
Ad

Answer this question