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

script.Parent is nil???

Asked by
lucas4114 607 Moderation Voter
8 years ago

I have no idea wtf is happening, this code outputs an error ( https://gyazo.com/0168b4b486c548001409a959119b0233 ) saying at line 27:

itemgui.Parent = script.Parent

that script.Parent is nil.. I don't know what is means because the script does have a parent: https://gyazo.com/e82f25bb51c3c57f9998a03b86e2036a Full code:


wait(2) local db = false script.Parent.Changed:connect(function(val) if db == false then db = true if val == "Visible" then if script.Parent.Visible == true then local itemstoload = game.ServerStorage.DATA_STORAGE:FindFirstChild(script.Parent.Parent.Parent.Parent.Name):FindFirstChild("Items"):GetChildren() for i,v in pairs (script.Parent:GetChildren()) do if v.Name ~= "Script" and v.Name ~= "EmptyItemGui" and v.Name ~= "UndoButton" then v:Destroy() end end local amountofitems = 0 for i,v in pairs (itemstoload) do local itemgui = game.ServerStorage.EmptyItemGui:Clone() local row = math.floor(i/3) itemgui.Position = UDim2.new(0,((i - (row * 3)) + 10),0,((row * 130) + 10)) itemgui.Text = v.Value itemgui.Script.Disabled = false itemgui.Parent = script.Parent amountofitems = i end script.Parent.CanvasSize = UDim2.new(0, 0, math.floor(amountofitems/6), 0) end end db = false end end)
0
Prolly because you are passing in a paramater.. and I believe frame does not have a Changed Function to use. scottmike0 40 — 8y
0
Nevermind, it seems Frame does have a Changed part, the problem with that loop there is using script.Parent inside the loop, which, if you know how Nodes work, eventually it will become null if itemstoload is larger than the amount of .Parents it can go to. scottmike0 40 — 8y
0
itemstoload was only 4 string values when I tested this.. lucas4114 607 — 8y
2
What is the script's name? User#6546 35 — 8y
View all comments (4 more)
0
This is rather peculiar koolkid8099 705 — 8y
0
"LoadItems" lucas4114 607 — 8y
1
You're destroying the Script, and therefore it doesn't have a Parent by the line you want. User#6546 35 — 8y
0
ooo ty I didn't notice that, I forgot to change in that if V.Name ~= "Script" to "LoadItems" when I changed the script's name.. lucas4114 607 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

You destroyed it
You were only supposed to blow the bloody doors off

Over on lines 12/13 you destroyed the Script because it wasn't one of those names. That meant that on line 27, the script had no Parent.

0
Thank you lol, I changed the name of the script to "LoadItems" but forgot to change that name in the script too lucas4114 607 — 8y
0
PS: check if its ClassName is "Script" instead: If v:IsA("Script") == false... XAXA 1569 — 8y
Ad

Answer this question