Changing Player Animation Pack In-game

Hey there!
How would I make a player’s animation pack change to a zombie animation pack after they get touched by a certain part? I have tried many times to do this, but it never works.

4 Likes

You could do something along the lines of this:

local character = game.Players.LocalPlayer.Character
local zombieanim = {

walk = "http://www.roblox.com/asset/?id=",

idle = "http://www.roblox.com/asset/?id="

}
for _, anim in pairs(character.Animate:GetChildred()) do
	if anim:IsA("StringValue") then
		anim.Value = zombieanim[anim.Name]
	end
end
3 Likes

I found a script to change animations in game (Jumping, running, walking, swimming ect…)
Just change the AnimationId into your custom animation and put it into StarterPlayers > StarterCharacterScripts as LocalScript.

--// Setup
speed = Instance.new("IntValue", script)
script.Parent:WaitForChild("LowerTorso")
script.Parent:WaitForChild("Humanoid")
game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0, 0.5, -0.95)

--// Walking
animation1 = Instance.new("Animation", script.Parent.Humanoid)
animation1.AnimationId = "http://www.roblox.com/Asset?ID=5771342396"
animTrack1 = script.Parent.Humanoid:LoadAnimation(animation1)
animation1.Name = "Walk"

--// Idle
animation2 = Instance.new("Animation", script.Parent.Humanoid)
animation2.AnimationId = "http://www.roblox.com/Asset?ID=5771360334"
animTrack2 = script.Parent.Humanoid:LoadAnimation(animation2)
animation2.Name = "Idle"
animTrack2:Play()

--// Jumping
animation3 = Instance.new("Animation", script.Parent.Humanoid)
animation3.AnimationId = "http://www.roblox.com/asset/?id=5771361520"
animTrack3 = script.Parent.Humanoid:LoadAnimation(animation3)
animation3.Name = "Jump"

--// Falling
animation4 = Instance.new("Animation", script.Parent.Humanoid)
animation4.AnimationId = "http://www.roblox.com/asset/?id=5771362399"
animTrack4 = script.Parent.Humanoid:LoadAnimation(animation4)
animation4.Name = "Fall"

--// Sprinting
animation5 = Instance.new("Animation", script.Parent.Humanoid)
animation5.AnimationId = "http://www.roblox.com/asset/?id=5771363294"
animTrack5 = script.Parent.Humanoid:LoadAnimation(animation5)
animation5.Name = "Run"

--// Sitting (Ignore it)
animation6 = Instance.new("Animation", script.Parent.Humanoid)
animation6.AnimationId = "http://www.roblox.com/asset/?id=5771364099"
animTrack6 = script.Parent.Humanoid:LoadAnimation(animation6)
animation6.Name = "Sit"

--// Landing
animation7 = Instance.new("Animation", script.Parent.Humanoid)
animation7.AnimationId = "http://www.roblox.com/asset/?id=5771365424"
animTrack7 = script.Parent.Humanoid:LoadAnimation(animation7)
animation7.Name = "Landding"

--// Crouch
animation8 = Instance.new("Animation", script.Parent.Humanoid)
animation8.AnimationId = "http://www.roblox.com/asset/?id=5771375230"
animTrack8 = script.Parent.Humanoid:LoadAnimation(animation8)
animation8.Name = "Crouch"

--// Climbing
animation10 = Instance.new("Animation", script.Parent.Humanoid)
animation10.AnimationId = "http://www.roblox.com/asset/?id=5771366547"
animTrack10 = script.Parent.Humanoid:LoadAnimation(animation10)
animation10.Name = "Climb"

--// Variables
Walking = false
Running = false
Jump = false

Terms = game:GetService("RunService")

--// Main script to execute animations at each actions
Terms.RenderStepped:connect(function(p2)
	if script.Parent:FindFirstChild("LowerTorso") ~= nil then
		script.Speed.Value = script.Parent.LowerTorso.Velocity.magnitude
	end
	if (script.Parent.LowerTorso.Velocity * Vector3.new(1, 0, 1)).magnitude >= 5 and (script.Parent.LowerTorso.Velocity * Vector3.new(1, 0, 1)).magnitude <= 18 then
		if Walking == false and Sitting == false then
			Running = false
			Walking = true
			animTrack1:Play()
			animTrack5:Stop()
			animTrack10:Stop()
		end
	elseif (script.Parent.LowerTorso.Velocity * Vector3.new(1, 0, 1)).magnitude > 18 then
		if Running == false and Sitting == false then
			Running = true
			Walking = false
			animTrack5:Play()
			animTrack10:Stop()
		end
	else
		Running = false
		Walking = false
		animTrack1:Stop()
		animTrack5:Stop()
	end
	if (script.Parent.LowerTorso.Velocity * Vector3.new(0, 1, 0)).magnitude >= 30 and Jump == false and Sitting == false then
		Jump = true
		animTrack3:Play()
		animTrack10:Stop()
		animTrack6:Stop()
		animTrack1:Stop()
		Walking = false
		wait(0.55)
		animTrack3:Stop()
		Jump = false
	end
end)

I don’t know if it works with R6. Mention if not working i’ll edit it.

1 Like

I’m looking for a way to change the animation packs, though. I haven’t made any custom animations, and I’m not very good at it. Thanks for the help, though!

The script i send already have custom R15 animations, you can use it. You’re welcome!

1 Like

Thanks, however, when I test it, it crashes Studio and lags a lot when it touches the part. The script I have fires a remote event when a part is touched, and that runs this script when it’s fired. However, I don’t know how to get rid of the lag, and still have it run the script.

If you’re looking for getting Zombie animation assets.
I use the google extension BTRoblox to get the asset id with a right-click!
You should try it!

How would I use that to trigger the animations when the player touches the certain part, though?
(Thanks, I’ll check it out.)

As I said, you have to find assets which are zombie animations (idle, walk, run, jump, and more).
Copy and paste the asset in the script gave by MyNameIsChaosity.
It should work. I don’t know what you’re trying to say by “trigger”. Some animations are made to be played in a loop, other animations are not.

The reason I say trigger is because the player animations are going to be normal until they touch, or get “infected” by a zombie npc, then that fires a remote event to enable a gui and will enable the script for the animations.
The new issue I’m having is that the way I tried to get the animation script to fire caused lots of lag, but I can’t figure out a different way to do it.

Oh I see. I’m not sure to be helpful for Programmation. I’m just a builder, designer, animator but not a scripter. You can enable and disable an animation pack with a few lines of script.

1 Like