Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation not working when played on player?

How the animation should look: How it looks on a player:

The priority on the animation is action, I don't know what could be interfering

Code on dummy (works fine when i run the game):

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://11262438869"

local a = script.Parent.Humanoid.Animator:LoadAnimation(anim)
a.Looped = true
a:Play()

Code on player in startercharacterscripts (doesn't work lol):

repeat task.wait() until script.Parent
local humanoid: Humanoid = script.Parent:WaitForChild("Humanoid")

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://11262438869"
local track = humanoid.Animator:LoadAnimation(anim)
track.Looped = true

humanoid.Running:Connect(function(s)
	if s > 0 then
		track:Play()
	else
		track:Stop()
	end
end)

2 comments

0

Could you send the code? I can't really help unless there is code to test.

0

LikeableEmmec, I changed my my question. There are no errors btw

1 answer

Hi, I made an animation system before. Put a script in StarterCharacterScripts. Then insert a folder in the script and rename it to Settings. In the folder place a boolvalue and a number value. Rename boolvalue to Enabled. Rename Numbervalue to Speed. Then insert animation into the script. Rename it to IdleAnimation. Make sure you go to properties tab and put your animation id into it. Here is the script:

--Variables--

local set = script.Settings

local sp = set.Speed

local enabled = set.Enabled

local hum = script.Parent:WaitForChild("Humanoid")

if hum then

	print("Success")

else

	print("No Humanoid")

end

local humanim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))



--Playing Animation--

if enabled.Value == true then

	humanim:Play()

	humanim.Looped = true

	humanim:AdjustSpeed(sp.Value)

end 

Hope this helps and you understand. let me know if it doesn't work or you got stuck.

4 comments

0

This isn't much different from my script except mine has checks for if they are running to play the animation.

0

This isn't much different from my script except mine has checks for if they are running to play the animation. I think the problem is that the normal walking animation is playing at the same time as my animation, but I don't see why since the priority

0

are u getting any errors

0

Also what weird is that it worked for me

This discussion is preserved as it was. New answers, comments, and votes are closed.