Hello,
I started making a game and wanted to play an animation right after the players character is spawning in. I normally know what to do and how it works but everything I tried so far doesn’t seem to work and I have no more ideas left on how I could fix it. Any help is appreciated.
-- // Variables
-- # Services
local playersService = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
-- # Objects
local player = playersService.LocalPlayer
local character = player.Character
local assets = replicatedStorage.Assets
local animations = assets.Animations
local idleAnimation = animations.Idle
-- // Functions
function onCharacterAdded(character: Model)
local humanoid = character:FindFirstChild("Humanoid")
local animator = humanoid:FindFirstChild("Animator")
local track: AnimationTrack = animator:LoadAnimation(idleAnimation)
track:Play()
end
if character then
onCharacterAdded(character)
end
player.CharacterAdded:Connect(onCharacterAdded)
Just for clarification, the script is in “StarterPlayerScripts”, I set the animation priority to: “Action”, and I made sure the animation is looping since it only has one keyframe.
2 Likes
try loading the animation by the humanoid not the animator?
1 Like
Doesn’t seem to work, my character still displays no animation. Thanks for the help though!
1 Like
i have just tested your code, and there doesn’t seem to be any problems occuring. so maybe you’re stopping all animations in a different code?, OR the animation isn’t your’s or the animation was deleted and all that
2 Likes
That’s interesting, but I don’t really have much code in this place currently. I only have a module and server script which both only have something to do with leaderstats. The animation was also made by me I even remade it just to be sure but still there’s no animation showing up, I guess my place is cursed or something.
the animation may be r15 aswell
No, I used R6 I’m sure of that.
yeah then i dont know what’s happening here, due to how the code worked for me.
try using roblox’s monster mash dance animation, if that doesnt work aswell, then your place do be cursed.
I tried using the other animation still nothing was shown. I know that It makes a track because I can print the track and it doesn’t give me some wrong value, so I guess I’m just cursed or Roblox wants to see my downfall for some reason.
if your game is made by a group, did you upload the animations to be made by the group?
i dont think it matters if the animation is uploaded to the group or not. if hes the owner of the animation it should work even if its not in the group
when i uploaded the animation to be made by me when the game is made by the group it didn’t work until i made the anim made by the group.
No, It’s my own place. Thanks for the help!
you’re welcome bro! i’ve mostly been an animator for a lot of small games.