Index nil with clone

what does that error mean? im trying to clone a part. im not destroying it, all i do is change its parent, is that the reason im getting the error?

Could you provide the code that’s giving the error?


Its, item:Clone() not item.clone

1 Like

no damn way i just said .clone lmaooo


still getting the error

Could you print(item) right after you fire the client and in the OnClientEvent connection. Tell me what they print

strange, for some reason it prints nil in thee local script
image

Could you ss the whole script including the parameters being sent for the OnClientEvent Connections (since you kind of cut it off in the screenshot)

here is the server module:
i dont think you need the whole function since only these 3 lines are associated with axe


and here is the full remote

game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Notification").OnClientEvent:Connect(function(item)
	local ts = game:GetService("TweenService")
	local plr = game.Players.LocalPlayer
	local main = plr:WaitForChild("PlayerGui"):WaitForChild("Notification").Main
	local templateclone = main.Parent.Template:Clone()
	local itemclone = item:Clone()
	itemclone.Parent = templateclone.ItemFrame
	local itemcam = Instance.new("Camera",itemclone)
	itemcam.Name = "ItemCam"
	local biggestSize
	local sizeTable = {}
	for i,v in pairs(itemclone.Parts:GetChildren()) do
		if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") then
			table.insert(sizeTable,v.Size.X)
			table.insert(sizeTable,v.Size.Y)
			table.insert(sizeTable,v.Size.Z)
		end
	end
	for i,v in pairs(sizeTable) do
		if biggestSize == nil then
			biggestSize = v
		elseif v > biggestSize then
			biggestSize = v
		end
	end
	if itemclone.Category.Value == "AxesAndPickaxes" or itemclone.Category.Value == "Saws" or itemclone.Category.Value == "Planks" then
		itemcam.CFrame = CFrame.new(itemclone.Parts:GetBoundingBox().p + Vector3.new(biggestSize,0,0),itemclone.Parts:GetBoundingBox().p)
	else
		itemcam.CFrame = CFrame.new(itemclone.Parts:GetBoundingBox().p + Vector3.new(biggestSize,biggestSize,biggestSize),itemclone.Parts:GetBoundingBox().p)
	end
	if itemclone.ToSave:FindFirstChild("Amount") ~= nil then
		templateclone.Text = "x"..itemclone.ToSave.Amount.Value.." "..itemclone.ItemName.Value
	else
		templateclone.Text = "x1 "..itemclone.ItemName.Value
	end
	templateclone.ItemFrame.CurrentCamera = itemcam
	templateclone.Parent = main
	wait(3)
	ts:Create(templateclone,TweenInfo.new(0.5),{BackgroundTransparency=1}):Play()
	ts:Create(templateclone,TweenInfo.new(0.5),{TextTransparency=1}):Play()
	ts:Create(templateclone.ItemFrame,TweenInfo.new(0.5),{ImageTransparency=1}):Play()
	templateclone:Destroy()
end)

Where is the item located? Is it in serverStorage or serverScriptService?

replicated storage im pretty sure, but ill print its parent to make sure.

nevermind, its nil. i think i got the issue. ill try to change its parent and i’ll see if it works

If your still getting the error than Instead of sending the item send a random string as a argument and see if it still prints nil. Try and see if there are any other threads/functions that are firing the function with NO item argument.

i sent a random string and i got this
image

Wait you just did item:Clone()
You might have to do game.Workspace.item:Clone – Change workspace to the original ones service also if “item” is in model add the models name before item

it has no parent, because item is a clone actually.
item is a clone of a tool template

O ok then we’ll I am advanced and new at the same time so I don’t know everything but have you tried like YouTube dev hub dev wiki?

idk maybe i just cant do remotes in a module? that wouldnt make sense tho

Could you confirm the rest of what I said?

Note that I mean’t the remote event and not function