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

script.Parent is nil???

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)

8 comments

0

Prolly because you are passing in a paramater.. and I believe frame does not have a Changed Function to use.

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.

0

itemstoload was only 4 string values when I tested this..

2

What is the script's name?

0

This is rather peculiar

0

"LoadItems"

1

You're destroying the Script, and therefore it doesn't have a Parent by the line you want.

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..

1 answer

✓ Accepted answer

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.

2 comments

0

Thank you lol, I changed the name of the script to "LoadItems" but forgot to change that name in the script too

0

PS: check if its ClassName is "Script" instead: If v:IsA("Script") == false...

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