Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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!

0
bruh it didn't tell the line spaces xXMannyto123Xx -5 — 2y
0
do you mean morphing the NPC? i do have the morph code. extrorobo 104 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
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.

Ad

Answer this question