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

Destroy not a valid member of a folder??

It's for a basic inventory system but it won't destroy the Folder when you run out of (insert object here) Here's the code

local item = script.Parent.Parent.Item
local quan = script.Parent.Parent.Quantity
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function ()
	if item.Value ~= " " then
		local obj = game.ReplicatedStorage.ITEMS:FindFirstChild(item.Value):clone()
		obj.Parent = player.Backpack
		if quan.Value > 0 then
			quan.Value = quan.Value - 1
		elseif quan.Value <= 0 then
			script.Parent.Parent:Destory()
			end
		end
end)

All I get in the output is "destroy is not a valid member of Folder". But I haven o clue hwy as I never had this error when trying to rid of something before? Any help?

1 comment

0

An alternative way might be parent = nil

1 answer

✓ Accepted answer

I'm sure this will make you facepalm, but on line 12 you spelled "Destroy" as "Destory". Change that, and your code should be working just fine:

local item = script.Parent.Parent.Item
local quan = script.Parent.Parent.Quantity
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function ()
	if item.Value ~= " " then
		local obj = game.ReplicatedStorage.ITEMS:FindFirstChild(item.Value):clone()
		obj.Parent = player.Backpack
		if quan.Value > 0 then
			quan.Value = quan.Value - 1
		elseif quan.Value <= 0 then
			script.Parent.Parent:Destroy() -- Let's not Destory it, but Destroy it instead :D
		end
	end
end)

Hope this helped, lol.

2 comments

0

Oh my, thank you lol.

0

Happened to me too lmao.

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