script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked) local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=147619125" -- your id here local animTrack =script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation) -- change Humanoid to the target's Humanoid animTrack:Play() end)
It works in test mode but not in a server
Unless you're loading in to a NPC ( not a character ) the wiki says it has to be a LocalScript.
--LocalScript in StarterGui or StarterPack repeat wait() until game.Players.LocalPlayer local PartName = "Part1" --Name of the part you want to click. local animationId = "http://www.roblox.com/Asset?ID=147619125" local p = game.Players.LocalPlayer local mouse = p:GetMouse() mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Name == PartName then local new = Instance.new("Animation") new.AnimationId = animationId p.Character.Humanoid:LoadAnimation(new):Play() end end)
script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked) local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=147619125" -- your id here local animTrack =playerWhoClick.Character:FindFirstChild("Humanoid"):LoadAnimation(animation) -- change Humanoid to the target's Humanoid animTrack:Play() end)
You aren't loading the animation on the script's parent, you want to find the character's humanoid so take the player value that the event returns and then find the character and it's humanoid then load the animation!