My script destroys parts when they touch the part the script is inside. I have tried but I cannot seem to make it so it does not destroy players.
Here is my script:
function tch(h)
if (h.Parent.Name == "Cheese Sandwhich") then
h.Parent:Destroy()
game:GetService("Chat"):Chat(script.Parent.Parent.Head, "Looks delicious! Thank you!", Enum.ChatColor.Blue)
else
h.Parent:Destroy()
game:GetService("Chat"):Chat(script.Parent.Parent.Head, "Ew! This isn't cheese! :(", Enum.ChatColor.Blue)
end
end
end
script.Parent.Touched:connect(tch)
And here is one of my attempts to fix the issue:
function tch(h)
if (h.Parent.Name == "Head") or (h.Parent.Name == "UpperTorso") or (h.Parent.Name == "LowerTorso") or (h.Parent.Name == "LeftUpperArm") or (h.Parent.Name == "LeftLowerArm") or (h.Parent.Name == "LeftHand") or (h.Parent.Name == "RightUpperArm") or (h.Parent.Name == "RightLowerArm") or (h.Parent.Name == "RightHand") or (h.Parent.Name == "RightUpperLeg") or (h.Parent.Name == "RightLowerLeg") or (h.Parent.Name == "RightFoot") or (h.Parent.Name == "LeftUpperLeg") or (h.Parent.Name == "LeftLowerLeg") or (h.Parent.Name == "LeftFoot") or (h.Parent.Name == "HumanoidRootPart") or (h.Parent.Name == "Humanoid") then
else
if (h.Parent.Name == "Cheese Sandwhich") then
h.Parent:Destroy()
game:GetService("Chat"):Chat(script.Parent.Parent.Head, "Looks delicious! Thank you!", Enum.ChatColor.Blue)
else
h.Parent:Destroy()
game:GetService("Chat"):Chat(script.Parent.Parent.Head, "Ew! This isn't cheese! :(", Enum.ChatColor.Blue)
end
end
end
script.Parent.Touched:connect(tch)
P.S. I don't know if this question is classed a request. Sorry if it is.
