Drink machine not working

Trying to make a roblox cafe drink dispenser with a screen attached. Where when a tool touches it, it updates the tools attributes and some objects inside of the tool.
Script isn’t working at all, I’ve tried using print statements to see where it breaks but none of them printed.

local Effect = script.Parent.Parent:WaitForChild('Effect')
local Pour = Effect.Liquid
local CircleFill = script.Parent.Parent.Screen.DrinkSelection.CircleFillTransition

script.Parent.Touched:Connect(function(Part)
	if Part.Parent.ClassName == "Tool" and Part.Parent.Name == "Small" then 
		local Drink = script.Parent.Parent.Screen.DrinkSelection.GetDrink:Invoke()
		if not Drink then return end
		CircleFill:TweenSize(UDim2.new(5,0,5,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3, false)
		script.Parent.Drink:Play()
		Pour.Color = Drink.Color
		Pour.Enabled = true
		task.wait(script.Parent.Drink.TimeLength) -- past here tool changes are made
		Part.Parent.Name = Drink.Name
		Part.Parent:SetAttribute("DrinkColor", Drink.Color)
		Part.Parent:SetAttribute("DrinkName", Drink.Name)
		Part.Parent:SetAttribute("has_Drink", true)
		Part.Parent.Liquid.Color = Drink.Color	
		Part.Parent.Liquid.Transparency = 0.65
	end
	script.Parent.Drink:Stop()
	Pour.Enabled = false
	CircleFill:TweenSize(UDim2.new(0,0,0,0), Enum.EasingDirection.In, Enum.EasingStyle.Quad, 0.3, false)	
end)

Can you verify the Touched event is firing? What lines have you ensured are correct?
Also, a side note, I’d recommend saving a variable for your detected tool.

local tool = Part:FindFirstAncestorOfClass("Tool")

The touched event doesn’t seem to be firing.
Lines 12, 18, 30 I know work

Do both parts (one from tool, one from machine) have CanTouch set to true?

The machine didn’t, but even with CanTouch enabled when the tool touches only the audio and the ui animation work. Although barely as the animation sometimes doesn’t go away and only goes away when the tool touches it again, with the audio only playing sometimes.

With this error showing in the console:

Change Pour.Color and Part.Parent.Liquid.Color to Pour.Color3 and Part.Parent.Liquid.Color3 and see if that works

Doesn’t work due for pour referencing a ParticleEmitter
Also doesn’t change Part.Parent.Liquid.Color to the new color

Ahh its a particle emitter!

For each do this:

.Color = ColorSequence.new{
    ColorSequenceKeypoint.new(0, Drink.Color),
    ColorSequenceKeypoint.new(1, Drink.Color)
}
1 Like

That seems to have worked, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.