I was trying to play an animation inside the player, but it didn't work and there's no errors. Please help! Here is the script I used.
Local Script
1 | local player = game.Players.LocalPlayer |
2 | local char = player.Character or player.CharacterAdded:Wait() |
3 | local uis = game:GetService( "UserInputService" ) |
4 |
5 | uis.InputBegan:Connect( function (key) |
6 | if key = Enum.KeyCode.E then |
7 | script.AnimationController:LoadAnimation(script.Animation):Play() |
8 | end |
9 | end ) |
Instead of an animationcontroller you should simply use the humanoid's LoadAnimation function and also please set the animation to a variable to allow it time to load.
also you need to do key.KeyCode, not key
01 | local player = game.Players.LocalPlayer |
02 | local char = player.Character or player.CharacterAdded:Wait() |
03 | local uis = game:GetService( "UserInputService" ) |
04 | local anim = char:WaitForChild( "Humanoid" ):LoadAnimation(script.Animation) |
05 |
06 | uis.InputBegan:Connect( function (key) |
07 | if key.KeyCode = Enum.KeyCode.E then |
08 | anim:Play() |
09 | end |
10 | end ) |