I’m trying to get the localplayer to play an animation, but they won’t move at all. The animation itself starts and the timeposition counts up, but the player doesn’t move at all. The same thing happens when testing it on a rig. No errors show up in the output when playing.
Animation part of the script:
local char = game.Workspace.Rig -- or the localplayer, this was for testing
local hmnd = char.Humanoid
local anim = hmnd.Animator:LoadAnimation(script.Animation)
anim.Looped = false
anim.Priority = Enum.AnimationPriority.Action4
anim:Play()
task.spawn(function()
while true do
task.wait()
print(anim.TimePosition) -- this is to check if it is running, it does increase as normal
end
end)
It is located in PlayerGui but my game doesn’t load in the player at the start, only when I need the character for the animation. So, the script is put into PlayerGui by a server script and then runs, and then fires an event for the server to load in the character and then plays the animation on the character.
Here is the part where it does that:
-- this script gets put into player gui by server, does other things before reaching here.
rps.Events.PlayerStart:FireServer() -- event to load character
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp:BasePart = char:WaitForChild("HumanoidRootPart")
local hmnd = char:FindFirstChildOfClass("Humanoid")
local animator = hmnd:FindFirstChildOfClass("Animator")
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = loc
hmnd.AutoRotate = false
hmnd.WalkSpeed = 0
hmnd.JumpHeight = 0
hrp.CFrame = ploc
hrp.Anchored = true
local anim = animator:LoadAnimation(script.StartAnim) -- animation inside script with anim id
anim.Priority = Enum.AnimationPriority.Action4
anim.Looped = false
anim:Play()
I’m not really sure if there is an issue with the animation itself as the :GetMarkerReachedSignal function runs when it’s supposed to during the animation, but the player doesn’t move at all. I also adjust the speed of the animation sometimes, if that affects anything.
No, changing the looped property doesn’t fix it. The only thing that happens is that the animation timer restarts (reaches 20 seconds which is the end, then restarts). The markers work as normal, they fire when the timer reaches them.
The character still doesn’t do anything though. They just continue playing the default idle animation. So, the only problem is the character doesn’t move at all, although the animation seems to be playing. I’ve check the animation itself and all the keyframes are there (made it in default Roblox animation editor).
Is the Animation ID correct and is the Animation owned by you? If so, I get the Animation KeyframeSequence (you can find it under your animations in toolbox) and change the animation priority and looping in the properties of that instead of in the script.
Yes, the animation is owned by me, I am working on this myself for now. The animation’s priority is set to the highest (Action4) in both the animation editor (in marketplace with highest priority) and in the script. The IDs are correct as well. As I said, the animation is running and has all the keyframes, but my own player character does not do anything, they just continue idling.
This is what the animation editor shows when I get it from toolbox:
the script is put into PlayerGui by a server script and then runs, […]
What does this mean? I’m quite surprised no one pointed this out.
I’ve been following this post since since its creation but didn’t answer because I was too lazy to go through 2FA.
Sorry if I wasn’t clear enough, I have CharacterAutoLoads disabled in my game, so GUI does not load in and no LocalScript can run as there is no player character, so I have to clone the GUI into the player’s gui when they join in. I only play the animation later when I load in the character through an event. Something like this (server script):
local ps = game:GetService("Players")
ps.CharacterAutoLoads = false
ps.PlayerAdded:Connect(function(plr)
-- other things like data loading
for _, v in script.StartingGUI:GetChildren() do v:Clone().Parent = plr.PlayerGui end
end)
someEvent.OnServerEvent:Connect(function(plr)
plr:LoadCharacter()
end)
For everyone confused about the GUI, I put a ScreenGUI with all the GUI stuff in it in the server script, which then is cloned into a joining player’s own PlayerGui.
This is what I meant:
All of the items in the StartingGUI folder get cloned to the player’s GUI, where LocalScripts can run.
Also, my issue is not related to the GUI at all. My script runs perfectly, the only issue is that the player does not move whilst the animation is running.
This could be related, but I created the animation with an R6 rig, but the account with the game is not, so does it mean that Roblox cannot play the R6 animation on the R15 player avatar? If so, then what if I made an R15 animation and someone with an R6 avatar tried playing the animation on their avatar?