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

How do I make it when I click a button, it plays a animation on a different model?

Asked by 4 years ago

Hello.

I’m trying to make a trick or treating system for one of my game updates. (Pre preparing) I’ve got it all down, now I just need to make the door bell. When I click the door bell. I want a animation to play on one of the models (DoorBellSysten, models inside: doorbell, door) Can anyone help me?

0
What model? Is it like a npc model? or are you animating the door? Just_Moop 27 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

So you would actually get the model's Animation Controller Instance (whether that be an AnimationController or Humanoid).

local model = workspace.Model; -- Change this to the model to play animation on
local animID = "AnimationID Here";
local animation = game.ReplicatedStorage.Animation or Instance.new("Animation");
animation.Parent = game.ReplicatedStorage;
animation.AnimationId = animID;
local player = model:FindFirstChildOfClass("Humanoid") or model:FindFirstChildOfClass("AnimationController");
local animationPlayer = player:LoadAnimation(animation);
-- To play, just do animationPlayer:Play();
0
I don’t get this, I thought it would be door = workspace.DoorBellSystem.Door doorbell = workspace.DoorbellSystem.Doorbell.Clickdetector on MouseButton1Click:Play(workspace.doorbellsystem.door.anim). Though I’m prolly completely wrong since I’m a noob. Can you explain what’s happening CrunchyRBLX 0 — 4y
Ad

Answer this question