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

LoadAnimation requires the AnimationController object to be a descendant of the game object?

LoadAnimation requires the AnimationController object (MP5.AnimationController) to be a descendant of the game object?

local Gun=game.ReplicatedStorage.GunStorage.MP5:Clone()
local Controller=Instance.new("AnimationController")
local ShootValue=game.ReplicatedStorage.GunValue.MP5:WaitForChild("ShootingAnim1").Value
local ShootAnim1 =Instance.new("Animation")
ShootAnim1.AnimationId ="rbxassetid://"..ShootValue
ShootAnim1.Parent=Gun
Controller.Parent=Gun
local LShootAnim1=Controller:LoadAnimation(ShootAnim1)

3 comments

0

You're supposed to load the animation onto the Humanoid, not an AnimationController.

0

stop @iiMayk

0

so anyone knows what wrong :(?

2 answers

LoadAnimation requires the Humanoid object (MP5.Humanoid) to be a descendant of the game object? umm...

local Gun=game.ReplicatedStorage.GunStorage.MP5:Clone()
local GunHum=Gun:WaitForChild("Humanoid")
local Controller=Instance.new("AnimationController")
--
local ShootValue=game.ReplicatedStorage.GunValue.MP5:WaitForChild("ShootingAnim1").Value
local ShootAnim1 =Instance.new("Animation")
ShootAnim1.AnimationId ="rbxassetid://"..ShootValue
--
ShootAnim1.Parent=Gun
Controller.Parent=Gun
local LShootAnim1=GunHum:LoadAnimation(ShootAnim1)

3 comments

0

Ignore the comments

0

you forgot to parent the animation controller

0

line 10

Basically you forgot to parent the animation on line 6

local ShootAnim1 =Instance.new("Animation")
ShootAnim1.AnimationId ="rbxassetid://"..ShootValue
ShootAnim1.Parent = gun
-- Parent the animation?

The animations do need to be in the game for them to work

Another EDIT

The more I look at yours it makes me think because I don't think you can load animations onto a object that isn't in workspace.

4 comments

0

oh I'm dumb didn't read it all the way XDDD

0

Hey GameboyOtaku, have you inserted an animation to a gun, if you had, can you tell me how you did it?, thanks!

0

yes I did in my game which is using the same thing you are doing I had a humanoid in the gun and did it like that

0

oh maybe it's because you didn't parent the cloned mp5 to workspace?

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