Gui is missing Error

There is an Error what says that inventory GUI is missing but i checked it and everthink is there so idk what i have to do to fix it

Error message:
Players.TapsoNNN.PlayerGui.Inventory.Manager:48: attempt to index nil with ‘Name’ - Client - Manager:48

Script ‘Players.TapsoNNN.PlayerGui.Inventory.Manager’, Line 48 - Studio - Manager:48

Line 48-51

if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
		local mat = script.Parent.Frame.ScrollingFrame[material.Name]	
end

Everythink is there so what is the problem???

2 Likes

What is “material” defined as?

1 Like

Manager
´´´
PlaceShow.OnClientEvent:Connect(function(material)

if debounce == false then
	if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
	local mat = script.Parent.Frame.ScrollingFrame[material.Name]	
	mat.Count.Value = mat.Count.Value -1
	mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
	material.Parent = game.Workspace	
	debounce = true
	wait(1)
	debounce = false
	end
end

end)

Build script (Server)
ADDEvent.OnServerEvent:Connect(function(plr,target,pos,Block)

local xBlock = Block:Clone()
local owner = xBlock:WaitForChild("owner")
owner.Value = plr.name
xBlock.Position = target.Position + pos
game:GetService("ReplicatedStorage").PlaceShow:FireClient(plr,xBlock)

end)

Build tool

script.Parent.Activated:Connect(function()
local target = mouse.Target
if target then
local surface = mouse.TargetSurface
local pos = Surface(surface)
Event:FireServer(target,pos,Block_Choice)
end
end)
´´´

Try using FindFirstChild

local mat = script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name)

this line is a problem
script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name)
i mean thisn is the error message

I have also a function to remove and this is working idk why

RemoveShow.OnClientEvent:Connect(function(material)	
	if debounce == false then
		if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
			local mat = script.Parent.Frame.ScrollingFrame[material.Name]
			mat.Count.Value = mat.Count.Value +1
			material:Destroy()

			mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
		else
			local clone = script.ImageButton:Clone()
			clone.Name = material.name
			clone.TextLabel.Text = material.Name
			clone.Count.Value = 1
			clone.Parent = script.Parent.Frame.ScrollingFrame
			material:Destroy()

		end
		debounce = true
		wait(1)
		debounce = false
		end
end)
local pos = Surface(surface)

What is this Surface() function?

It basicaly look how to place the block and in which direction

local function Surface(surface)
	if surface.Name == "Top" then
		pos = Vector3.new(0,4,0)
	elseif surface.Name == "Bottom" then
		pos = Vector3.new(0,-4,0)
	elseif surface.Name == "Front" then
		pos = Vector3.new(0,0,-4)
	elseif surface.Name == "Back" then
		pos = Vector3.new(0,0,4)
	elseif surface.Name == "Left" then
		pos = Vector3.new(-4,0,0)
	elseif surface.Name == "Right" then
		pos = Vector3.new(4,0,0)
	end
	return pos
end

I’m confused because you never set the instances parent or an instance with the same names parent to script.Parent.Frame.ScrollingFrame

i added all the material by chilld added

player.ChildAdded:connect(function()

	while added ==0 do
		for i, material in pairs(inv:GetChildren()) do

			for e = 1, material.Value, 1 do
				print("ADD Item to Inv")
				if debounce == false then
					if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
						local mat = script.Parent.Frame.ScrollingFrame[material.Name]
						mat.Count.Value = mat.Count.Value +1
						mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
					else
						local clone = script.ImageButton:Clone()
						clone.Name = material.name
						clone.TextLabel.Text = material.Name
						clone.Count.Value = 1
						clone.Parent = script.Parent.Frame.ScrollingFrame


					end
					debounce = true
					wait(0.01)
					debounce = false
				end
			end
		end
		added=added+1	
	end
end)

And there is always 1 material but the count change

Try to add an wait for child:
script.Parent.Frame.ScrollingFrame:WaitForChild(material.Name)
script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name)

Still the same Error i really dont understand because on removing block everthinks works clear but by adding not

Where you have the error.
Let me take a look what line do you have the error?

Still the same Error i really dont understand because on removing block everthinks works clear but by adding not

Can you send the whole script, like how u have it right now?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local debounce = false
local open = false
local RemoveShow = ReplicatedStorage:WaitForChild('RemoveShow')
local PlaceShow = ReplicatedStorage:WaitForChild('PlaceShow')
local added = 0
local inv = player:WaitForChild("Inv")
script.Parent.Open.MouseButton1Click:Connect(function()
	if open == false then
		script.Parent.Frame.Visible = true
		open = true
	else
		script.Parent.Frame.Visible = false
		open = false
	end
end)

This below Works why?

RemoveShow.OnClientEvent:Connect(function(material)	
	if debounce == false then
		if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
			local mat = script.Parent.Frame.ScrollingFrame[material.Name]
			mat.Count.Value = mat.Count.Value +1
			material:Destroy()

			mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
		else
			local clone = script.ImageButton:Clone()
			clone.Name = material.name
			clone.TextLabel.Text = material.Name
			clone.Count.Value = 1
			clone.Parent = script.Parent.Frame.ScrollingFrame
			material:Destroy()

		end
		debounce = true
		wait(1)
		debounce = false
		end
end)

This below dont Work

PlaceShow.OnClientEvent:Connect(function(material)	

	if debounce == false then
		if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
			local mat = script.Parent.Frame.ScrollingFrame[material.Name]	
			mat.Count.Value = mat.Count.Value -1
			mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
			material.Parent = game.Workspace
		else
			local mat = script.Parent:WaitForChild("Frame").ScrollingFrame[material.Name]	
			mat.Count.Value = mat.Count.Value -1
			mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
			material.Parent = game.Workspace
			
		end
		debounce = true
		wait(1)
		debounce = false
		
	end
end)

Works below

player.ChildAdded:connect(function()

	while added ==0 do
		for i, material in pairs(inv:GetChildren()) do

			for e = 1, material.Value, 1 do
				print("ADD Item to Inv")
				if debounce == false then
					if script.Parent.Frame.ScrollingFrame:FindFirstChild(material.Name) then
						local mat = script.Parent.Frame.ScrollingFrame[material.Name]
						mat.Count.Value = mat.Count.Value +1
						mat.TextLabel.Text = material.Name.." x"..mat.Count.Value
					else
						local clone = script.ImageButton:Clone()
						clone.Name = material.name
						clone.TextLabel.Text = material.Name
						clone.Count.Value = 1
						clone.Parent = script.Parent.Frame.ScrollingFrame


					end
					debounce = true
					wait(0.01)
					debounce = false
				end
			end
		end
		added=added+1	
	end
end)

is this in a local or server script?

the whole Script is a LocalScript

Are you sure you are sending a instance and not a string? Through the event?

i think i know what the problem is and it is in a tool i am propably not sending the block thats the code

-- Variables

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService('UserInputService')
local RS = game:GetService('ReplicatedStorage')
local tool = script.Parent
local Event = RS:WaitForChild('PlaceBlock')
local pos
local SBLOCK = player:WaitForChild('PlayerGui'):WaitForChild('Inventory').Frame.SBLOCK
-- Surface Detection

local function Surface(surface)
	if surface.Name == "Top" then
		pos = Vector3.new(0,4,0)
	elseif surface.Name == "Bottom" then
		pos = Vector3.new(0,-4,0)
	elseif surface.Name == "Front" then
		pos = Vector3.new(0,0,-4)
	elseif surface.Name == "Back" then
		pos = Vector3.new(0,0,4)
	elseif surface.Name == "Left" then
		pos = Vector3.new(-4,0,0)
	elseif surface.Name == "Right" then
		pos = Vector3.new(4,0,0)
	end
	return pos
end


-- Block Selection

local num = 1
local blocks = RS.Blocks:GetChildren()
local Block_Choice = blocks[1]

numberOfBlocks = #blocks

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		num += 1
		Block_Choice = blocks[num]
		if blocks[num] == nil then
			num = 1
			Block_Choice = blocks[1]
			SBLOCK.Text ="Selected Block: "..Block_Choice.Name
		end
	end
end)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		num -= 1
		Block_Choice = blocks[num]
		if blocks[num] == nil then
			num = numberOfBlocks
			Block_Choice = blocks[numberOfBlocks]
			SBLOCK.Text ="Selected Block: "..Block_Choice.Name
		end
	end
end)

-- Place Block

script.Parent.Activated:Connect(function()
	local target = mouse.Target
	if target then
		local surface = mouse.TargetSurface
		local pos = Surface(surface)
		Event:FireServer(target,pos,Block_Choice)
	end
end)

i dont really know what exacly is wrong :confused: