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

How do I fix this error with a vending machine?

So, I am trying to make a vending machine work but it keeps giving me this error.

Foods is not a valid member of Model

I don't know what to do to fix this, so I am asking for help.

The script that is in one of the items is below. By the way, the vending machine has two of the same tools named different. For example

Tool1 or Tool2

local Thetool = script.Parent.Parent.Parent.Foods.Taco

function onClick()
	local Tool = Thetool:Clone()
	Tool.Parent = game.Workspace
	Tool.Handle.Position = script.Parent.Parent.Parent.Position
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

That is from one of the buttons.

2 answers

99% sure this is a troll dude anyway

local Thetool = game:FindFirstChild("Taco",true)

function onClick()
    local Tool = Thetool:Clone()
    Tool.Parent = workspace
    Tool.Handle.Position = script.Parent.Parent.Parent.Position
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)

This should work if not then "Tool.Handle.Position = script.Parent.Parent.Parent.Position" is your problem and you should check if the script.parent.parent,parent is really a part or union.

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