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

Why does my coffee machine only work once?

function tch(h)
if (h.Parent.Name == "Cup (Empty)") then
h.Parent.Name = "Espresso"
script.Parent.Parent.Spill.Transparency = 0.1
wait(0.5)
script.Parent.Parent.Spill.Transparency = 1
h.Parent.Drink1.BrickColor = BrickColor.new(21)
h.Parent.Drink1.Transparency = 0.1
end
end

script.Parent.Touched:connect(tch)

That is the script I am using.

My coffee machines only work once with a cup. After that, I could put the cup in a million times and it wont work. What am I doing wrong?

I got this script from someone else, but I made changes to the names (Espresso, Cup (Empty), etc)

1 comment

0

Probly because its Parented in Character, or because the Name is changed onTouch.

1 answer

You initially check the name of the touched object (line 02); you require that it be "Cup (Empty)".

But, on line 03, you change the name of the touched object to "Espresso". "Espresso" is not "Cup (Empty)", so given that nothing else will change it back, the part will never again be accepted by this function.

This means that you need to change the name back at some point.

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