Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to change a Rig (Humanoid NPC) face via the touch of a part?

I am trying to make a NPC face texture change if you touch a certain part (with the same parents). Here is a exemple of a script i tried to execute (under many angles):

debounce = false script.Parent.Touched:connect(function(hit) if not debounce then debounce = true if(hit.Parent:FindFirstChild("Humanoid")~=nil)then local player = game.Players:GetPlayerFromCharacter(hit.Parent) script.Parent.CanTouch = false script.Parent.face.Texture = "rbxassetid://x" wait(1.5) end debounce = false end end)

This above script has as parent the Head of the dummy. Now, here's the script I put in a "TriggerPart" in the dummy.

debounce = false script.Parent.Touched:connect(function(hit) if not debounce then debounce = true if(hit.Parent:FindFirstChild("Humanoid")~=nil)then local player = game.Players:GetPlayerFromCharacter(hit.Parent) script.Parent.CanTouch = false script.Parent.Dummy.Head.face.Texture = "rbxassetid://x" wait(1.5) script.Parent.Dummy.Head.face.Texture = "rbxassetid://x" wait(10) end debounce = false end end)

Yet, the script above don't have a single effect on the face of the dummy, if someone could help me, i'd really apreciate it! (btw i'm a begginer and really bad scripter, and the "x" remplace the texture Id in-game.)

Thanks!

2 comments

0

bruh it didn't tell the line spaces

0

do you mean morphing the NPC? i do have the morph code.

1 answer

script.Parent.Touched:Connect(function(TPart)
	local Human = TPart.Parent:FindFirstChildWhichIsA("Humanoid")
	if Human then
		TPart.Parent.Head.face.Texture = "rbxassetid://6399193086" -- Replace this number with id of the image you would like to use.
	end
end)

replace the 6399193086 with the image id you would like to use.

This discussion is preserved as it was. New answers, comments, and votes are closed.