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

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

Asked by
lazolv 7
2 years ago
Edited by Xapelize 2 years ago

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]

0
can you format your code? Puppynniko 1059 — 2y
0
formatted Xapelize 2658 — 2y

1 answer

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago

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
Ad

Answer this question