Idle Animation not changing

I am trying to make something where your idle animation changes as soon as you join the game but I have a problem where the script doesnt even recognise when the player has loaded into the game:

 local Players = game:GetService("Players")
--local JumpAnimation = "rbxassetid://13325948092"

local IdleAnimation = "rbxassetid://16974742908"

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")

	if character:WaitForChild("Animate") then
	--animatescript.jump.JumpAnim.AnimationId = JumpAnimation
	character.Animate.idle.Animation1.AnimationId = "rbxassetid://16974742908"
	character.Animate.idle.Animation2.AnimationId = "rbxassetid://16974742908"
	local LoadedAnim = humanoid.Animator:LoadAnimation(IdleAnimation)

local function OnPlayerAdded(player)

Maybe its me not thinking properly but I do not see any poblems in this script, and the output didnt recognise any errors either. I put this script in StarterCharacterScripts

1 Like

Try something more like:

local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local loaded = Player:HasAppearanceLoaded()
while not loaded do loaded = Player:HasAppearanceLoaded() task.wait() end

You have it setup like a Server script.

1 Like

Not sure if this is how you wanted it, but I tested this on a 2 player local server and it works fine for me.

Put this in a LocalScript and place in StarterCharacterScripts

--local JumpAnimation = "rbxassetid://13325948092"
local animId = "rbxassetid://16974742908"

local animate = script.Parent:WaitForChild("Animate")
animate.idle.Animation1.AnimationId = animId
animate.idle.Animation2.AnimationId = animId
--animate.jump.JumpAnim.AnimationId = JumpAnimation

You could also just copy the Animate localscript (which you can get by testing the game in studio, finding it in the character’s model, then copying the instance) and place it inside StarterCharacterScripts as stated here: StarterCharacterScripts | Documentation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.