-
What do you want to achieve?
This script is located under a part. When the tool named “Chocolate Cookie Batter” touches the part, I want it to execute a function. -
What is the issue?
It isn’t detecting when the tool touches the part.
local part = script.Parent
local detectorOne = part.Detector1
local detectorTwo = part.Detector2
local detectorThree = part.Detector3
local function cook(partThatTouched, newPartName, player)
partThatTouched:Destroy()
print("Cooking your food...")
wait(5)
print("Done!")
local newPart = game.ReplicatedStorage.FoodItems.CookedTools[newPartName]:Clone()
newPart.Parent = player.Backpack
end
detectorOne.Touched:Connect(function(hit)
-- Here is where it doesn't work (can't detect the tool)
if hit.Parent.Name == "Chocolate Cookie Batter" then
print("It is a valid part")
cook(hit.Parent, "Chocolate Cookie", game.Players:GetPlayerFromCharacter(hit.Parent.Parent))
end
end)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried searching in the DevForum and on Google but I couldn’t find anything.