Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

1 comment

0

you would just load and play the animation?

1 answer

✓ Accepted answer

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!

1 comment

0

Amazing dude, Thank you soo much!

This discussion is preserved as it was. New answers, comments, and votes are closed.