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

How do I fix this error with a vending machine?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

Its not coming out of my giver or even working

Answer this question