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

Roblox lua basically denies an item being parented to the required folder, WHY?

What I want to do is rename a mesh part in player's inventory folder for further use, but despite everything being pretty simple I get this:

"Carpet is not a valid member of Players.lazolv.Inventory.Items.Slot1"

It is a client side error and the script I use is a local script in a gui frame

-- there are some variables but all their names should be explaining what do they mean

if Items.Slot1:FindFirstChild("Carpet") and inventory.Equipment.ESlot2:FindFirstChild("PlasticBag") then
	script.Parent.TextBox.Sound2:Play()
	wait(3)			
	Items.Slot1.Carpet.Name = "DryCarpet"
	ItemFrame.ImageLabel.Image = "rbxassetid://6116102064"
	ItemFrame.TextBox.Text = "Press Y to drop or carry this garbage"
	ItemFrame.Sample.Text = "Dry carpet"
	print(Items.Slot1.Carpet.Name.." is the name of the thing")
      Items.Slot1.Carpet.Name = "DryCarpet"
end

Once it reaches the name part I see the error, the print line makes it print item name in output. The funny thing is that it says the required item doesnt exist despite printing its name a moment earlier lol

[my own thoughtsbe like: "why yes I say that the sky is blue and deny it a moment later" - roblox lua]

2 comments

0

can you format your code?

0

formatted

1 answer

Maybe the reason why Items.Slot1.Carpet is gone after the 3 seconds wait, is because you equipped the Carpet in the meantime and it's gone from your backpack (no longer exists)

Save the carpet tool in a variable so you can never lose it!

-- there are some variables but all their names should be explaining what do they mean

local Carpet = Items.Slot1:FindFirstChild("Carpet")
local PlasticBag = inventory.Equipment.ESlot2:FindFirstChild("PlasticBag")

if Carpet and PlasticBag then
    script.Parent.TextBox.Sound2:Play()
    wait(3)         
    Carpet.Name = "DryCarpet"
    ItemFrame.ImageLabel.Image = "rbxassetid://6116102064"
    ItemFrame.TextBox.Text = "Press Y to drop or carry this garbage"
    ItemFrame.Sample.Text = "Dry carpet"
    print(Carpet.Name.." is the name of the thing")
    Carpet.Name = "DryCarpet"
end

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