I am making a coffee shop, and I would like to know what I am doing wrong. I am trying to make an ability to add flavor to a coffee cup that is active in their hand. Please inform me what I am doing wrong. Also, please note: I have not added the tool switch code yet, what is there is just to kill the player so I can test it.
local function onPartTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local part = script.Parent
local cup = humanoid.Character:FindFirstChild("Decaf") or humanoid.Character:FindFirstChild("Mocha") or humanoid.Character:FindFirstChild("Regular") or humanoid.Character:FindFirstChild("Frappe") or humanoid.Character:FindFirstChild("HotCococa") or humanoid.Character:FindFirstChild("Latte")
local debounce = false
if cup then
humanoid.Health = 0
end
end
end
part.Touched:Connect(onPartTouched)
If possible, is there a way to be able to rename a tool without having to make a whole new one?

1 comment
Who uses :FindFirstChildWhichIsA() ??? I use :FindFirstChildOfClass()