Cup script not working

Hello, I’ve made a drink machine script with Proximity prompts, but whenever I test it, It doesn’t work. could anyone help me thanks!

I’ve checked output and there are no errors.

1 Like

Well, first of all there is no Part parameter, the first parameter (and the only one I know) is the player that triggered the prompt. So you are checking if player.Parent (game.Players) .Name == "PlasticCup" which as you can see now, is clearly not

1 Like
  1. Change the Part parameter to Player.
  2. Change the Part.Parents to Part.
  3. Right after you connect to the event, you need to put the following bit of code.
    local Part = Player.Character:FindFirstChild("PlasticCup") or Player.Backpack:FindFirstChild("PlasticCup")
    if not PlasticCup then
        return
    end

Should fix your script if you do it correctly.

2 Likes

You coded it wrong. ProximityPrompts give a Player I believe.

for _, v in pairs(Part.Character:GetDescendants()) do
if v.Parent:IsA("Tool") and v.Name=="Handle" and v.Parent.Name=="Drink" then
v.BrickColor = BrickColor.new("Burnt Sienna")
v.Transparency = 0
end
end

replace that as it is present in your code.

1 Like

Did you try my reply? Did it not work?

Your reply works, but I don’t believe the drink dispenser should be looking for a cup in the backpack. I also sensed that the part was actually a Handle in a Tool, so that’s why I added a few conditional statements.

That’s if there’s a delay between the Prompt being Triggered, and the Trigger event being fired, and the player somehow manages to unequip during that delay.

That’s my reasoning for step 2.

I did notice that you were using FindFirstChild, which seems like a better design from my understanding. But also, I have been getting strange errors in the output that say “Exception while signaling: Must be a LuaSourceContainer” and I cannot solve a single one of them. I do know that they occur when I sometimes use FindFirstChild or IsA in an unsynchronized thread.

1 Like

Idk whats wrong, but this just randomly started popping up.

What does your code look like now? I know how to fix this error, but I need to know what is causing it.

You forgot to add something to your code. You did not add a reference to Part. You must connect the event to the proximity prompt and put that code inside of the function.

1 Like

Ohh, ok. I’ll try that right now.

I connected the Proximity Prompt event to the script, but for some reason the drink part still doesn’t work.

What does your code look like now?

What is the name of the drink you have? It should be named “Drink” according to this script.

Edit: Wait, I noticed the problem. You have two variables named “Part”.

Which “Part” should I change, (function, or .Character?

Edit: Nvm, I see.

Is this what it should look like?