Local script:
The error is the topic’s name. Can anyone help me?
Local script:
The error is the topic’s name. Can anyone help me?
You need to create an animation object with that ID as it’s animationId then load that animation object.
The LoadAnimation function of the humanoid expects a animation instance and not an animation id
so what you have to do is to create an animation instance and add the animation id to that.
Here is some code i wrote in notepad so i might have messed up the syntax here and there
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://your id here"
Animation.Parent = --Where you want to store the animation
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local anim = Humanoid:LoadAnimation(Animation)
This is the old way of doing it, please use humanoid.animator:LoadAnimation for newer work, thanks!
is this your entire code? or do we only see a part?
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.F then
local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation([animationid here])
anim:Play()
end
end)
Even if that is the whole code that wouldn’t matter because the reason it doesn’t work is because of the animation instance.
Probably they just need to edit the animation then?
That’s right, they just need to add an instance.
ohh yeah,
local anim = Instance.new("Animation", plr.Character.Humanoid)
anim.AnimationId = [animation id here]
Actually, it doesn’t need to be inserted in the character’s humanoid, it just needs the animation id, then it would be programmed to load in the character humanoid.
local animPlayer = plr.Character.Humanoid:LoadAnimation(anim)
animPlayer:Play()
This is literally the same thing as my script and it doesn’t work.
If I add an Animation and include the ID inside workspace, and script the local script to make it load in the humanoid, will that work as well?
Do I had to instance it in a script or I can just already put the animation in workspace?
You can, you could’ve just checked the developer hub.
Or if it doesn’t contain stuff you need, then the first line i said is the solution to that confusion.