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

Is There Any Way To Make It So When You Touch A Part It Plays An Animation?

Asked by 7 years ago

Ill explain in more detail here. Is there a way you can make it so when I player touches a part it will start a cutscene using the cutscene plugin. I know how to do that but the part I am asking for is after the player touches the part and the cutscene starts the object in the cutscene lets say a ROBLOX character he will start waving or walking or playing some sort of animation. You should be able to have a command saying if player touched run animation. You know but I am just a little confused I wanna make a cutscene for my game and I was wondering how?

0
you would just load and play the animation? User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by
davness 376 Moderation Voter
7 years ago
Edited 7 years ago

That is pretty simple. You need to use the Touched event, and bring the animation you have.

Since you will perform camera manipulation along with the animations, a LocalScript will bring you better results (by eliminating lag)

1. Get and store what you want

First, you need to tell the script where are the instances you need to do that animation:

local part = --write here
local animation = --write here

2. Loading the animation

Once you get the animation, you should load it into the player. Since it is a LocalScript, you may use the LocalPlayer property:

local animationTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation)

3. Listening to the touch event and start the animation!

Every part has a Tocuhed event that is fired when it is touched by something. You can use it then to trigger your event.

Final script

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)

Hope I helped!

0
Amazing dude, Thank you soo much! Kofikingston9000 -17 — 7y
Ad

Answer this question