For me its my first time using animation in scripts and I am having some issues with playing the script. The script is client-sided and gives no error code.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local remote = ReplicatedStorage.Events.Remote:FindFirstChild("RemoteEvent")
local Players = game:GetService("Players")
local Debounce = true
local Animation = ReplicatedStorage.Assets.Animations.TestAnimEvent
local Humanoid = Players.LocalPlayer.Character:FindFirstChild("Humanoid")
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent, mouse)
if gameProcessedEvent then return end
if Debounce == false then return end
if input.KeyCode == Enum.KeyCode.E then
Debounce = false
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
local mouse = Players.LocalPlayer:GetMouse()
remote:FireServer(mouse.Hit)
wait(1)
Debounce = true
end
end)
1&2. its in StarterPlayerScripts
3 I don’t think that would work because if that is so how can the remote event after that be fired if there’s an error
If the animation loads but nothing plays and there are no errors, the most common cause is that the animation is not being loaded through the Animator object or the animation asset is not owned by the correct creator.
Make sure your character actually has an Animator inside the Humanoid, and always load animations from there. Also confirm that the AnimationId is in this format:
rbxassetid://1234567890
Here is a simple working pattern:
local humanoid = character:WaitForChild(“Humanoid”)
local animator = humanoid:WaitForChild(“Animator”)
local track = animator:LoadAnimation(animation)
track:Play()
Another thing to check is ownership. If the animation was created under your personal account but the game belongs to a group, the animation will not play unless it is published under that same group.
Typical checklist:
AnimationId uses rbxassetid:// format
Animation is owned by the same user or group as the game
Animator exists inside the Humanoid
Animation priority is set high enough, usually Action
I made a short step by step tutorial that shows the full workflow from creating the animation to publishing and playing it in a script, including the ownership and priority parts:
As @TheKozzz suggested, make sure that your animaton is uploaded under the game’s creator.
(If your animation is owned by a group, set the animation’s Creator to that group. Otherwise, only the creator will be able to see it, but it should typically throw an error.)
Check if your Animation Object has the correct animation ID. If it does, try re-uploading the animation or set its Priority to Action4.
Not true. There are cases when the AnimationPriority needs to be Walk, Idle etc. It really depends on your use case.
Let’s say you have a sword animation. When you click, you want it to play a swing animation. Let’s say you are walking and you want to attack someone. Because your AnimationPriority is set to Idle, the walking animation “overrides” all the moving parts (moving parts as in all the parts that you moved within the animation). If you have a walking animation that for some reason does NOT move the left hand, your animation will animate the left hand because it is not overridden by anything. AnimationPriority Documentation
Action4 has the highest priority, followed by Action3, Action2 and Action.
Buddy this is more than 2 years old can you not bump ancient posts
(also i’d like to say it is true lmao, most people play custom animations and they will blend with eachother if not prioritized properly)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local UserInputService = game:GetService(“UserInputService”)
local Players = game:GetService(“Players”)
local remote = ReplicatedStorage.Events.Remote:WaitForChild(“RemoteEvent”)
local Animation = ReplicatedStorage.Assets.Animations:WaitForChild(“TestAnimEvent”)
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild(“Humanoid”)
local Animator = Humanoid:WaitForChild(“Animator”)
local Debounce = true
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if not Debounce then return end
if input.KeyCode == Enum.KeyCode.E then
Debounce = false
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack:Play()
local mouse = player:GetMouse()
remote:FireServer(mouse.Hit)
task.wait(1)
Debounce = true
end