I was making an infection game (and infection pack) and I try to use this script:
local part = script.Parent local faceLink = "rbxasset://20418518" local function onPartTouched(otherPart) -- Get the other part's parent local partParent = otherPart.Parent -- Look for a humanoid in the parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then -- Do something to the humanoid, like set its health to 0 partParent.Head.Face[0]:Destroy() partParent.Head.Face.Texture = faceLink end end part.Touched:Connect(onPartTouched)
and it does not work! How do I make the face change?
You destroyed the face before you change the face texture. Your script should be like this:
local part = script.Parent local faceLink = "rbxasset://20418518" local function onPartTouched(otherPart) -- Detect if there is humanoid, I did a mistake in here, the reason of detecting humanoid is because detect if it's a valid character if otherPart.Parent:FindFirstChild("Humanoid") then -- Get the other part's parent local partParent = otherPart.Parent -- Set the face to faceLink partParent.Head.Face.Texture = faceLink end end part.Touched:Connect(onPartTouched)