I want to make it so when I touch a certain part,an animation plays in a certain npc. I found a script on the web but I don't know how to use it or if it is right. Btw I'm terrible at scripting.
local part = --write here local animation = --write here local animationTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation) part.Touched:connect(function(p) if game.Players:GetPlayerFromCharacter(p.Parent) = game.Players.LocalPlayer then animationTrack:Play() --add more code end end)
First: Create a Part and an Animation in your workspace.
Replace your script for this(Its like the one you posted but it works for NPCs(Yours Works for players))
local part = game.Workspace.Part local animation = game.Workspace.Animation animation.AnimationId = "http://roblox.com/Asset?ID=467504759" part.Touched:Connect(function() local animationTrack = game.Workspace.NPC.Humanoid:LoadAnimation(animation) animationTrack:Play() end)
You can change the animation ID at line 3 for the ID of the animation of your choice(I made one as a sample, you can use it if you want to)
You can replace the word "NPC" at line 6 for the name of your NPC.
Now just touch the part.Here ill send some results:
Before touching it: http://prntscr.com/qdecl5
After touching it(Couldn't make a video sry): http://prntscr.com/qded0p
Contact me if you have any issues with the script.