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

Why does my coffee machine only work once?

Asked by 9 years ago
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)

0
Probly because its Parented in Character, or because the Name is changed onTouch. TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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.

Ad

Answer this question