How to make an NPC animation play when you press the E button

I want to make when you use proximity promt then the animation of the NPC starts playing

1 Like

I did the basic and not the best way as so “Humanoid:LoadAnimation()” deprecated.

local ProximityPrompt = script.Parent --Change the location of the instances
local NPC = script.Parent.Parent.Parent
local Humanoid = NPC:WaitForChild("Humanoid")
local Animation = NPC:WaitForChild("Animation")

local function AnimPlay()
	local animation = Humanoid:LoadAnimation(Animation):Play()
end

ProximityPrompt.Triggered:Connect(AnimPlay)

its doesnt work( (limit9234929349)

The DevForum is not a place to get stuff scripted for you.

If you want to make a system like this, I’d suggest researching about Proximity Prompts and Animations

Some useful articles:

1 Like

Can you tell me in detail?

Where did you insert the script, animation, ProximityPrompt?

Do you have a server script or a local one?

Did you change the location of the variables in the first 4 lines?

ProximityPromt im placed in Torso.
Script in ProximityPromt.
Animation in script.

I didn’t change the first 4 lines because I couldn’t understand (I’m bad at scripts)