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 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.