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

How can I give a team its own walk and idle animations?

I have this script in server script service that changes the walk speed of my zombie team. I want my zombie team to have its own idle and walk animations specific to that team. How can I do this? I want to make it so if the zombie isn't moving, it plays the idle animation. When the zombie moves, it plays the walk animation. Please help!

Here's the script: local Players = game:GetService("Players") local Team = game:GetService("Teams")["Zombie"]

local function onCharacterAdded(character) local plr = Players:GetPlayerFromCharacter(character)

if plr.Team == Team then
	character:WaitForChild("Humanoid").WalkSpeed = 11

end

end

local function onPlayerAdded(player)

if player.Character then
	onCharacterAdded(player.Character)
end

player.CharacterAdded:Connect(onCharacterAdded)

end

Players.PlayerAdded:Connect(onPlayerAdded)

1 answer

Check this out!

I recommend using Team.PlayerAdded instead since it fires whenever a player is assigned to that team.

local Teams = game:GetService("Teams")
local Team = Teams:WaitForChild("Zombie")

Team.PlayerAdded:Connect(function(newTeammate)
	local character = newTeammate.Character or newTeammate.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	
	humanoid.WalkSpeed = 11
	
	for _, playingTrack in ipairs(animator:GetPlayingAnimationTracks()) do
		playingTrack:Stop(0)
	end
	
	local animateScript = character:WaitForChild("Animate")
	-- change [PUT ANIMATION ID HERE] to the animation id you want
	animateScript.run.RunAnim.AnimationId = "rbxassetid://[PUT ANIMATION ID HERE]" -- example is 656118852 which is the ninja run
	animateScript.walk.WalkAnim.AnimationId = "rbxassetid://[PUT ANIMATION ID HERE]" -- example is 619522849 which is the robot walk
	animateScript.idle.Animation1.AnimationId = "rbxassetid://[PUT ANIMATION ID HERE]" -- example is 10921155160 which is the ninja idle 1
	animateScript.idle.Animation2.AnimationId = "rbxassetid://[PUT ANIMATION ID HERE]" -- example is 10921155867 which is ninja idle 2
end)

If this still doesn't work try creating your custom Animate script by following this guy!

4 comments

0

This does nothing.

0

Is this a local script and does it go in serverscriptservice, or startercharacterscripts or maybe starterplayerscripts?

0

it's a normal script in serverscriptservice

0

if it still doesn't work i put a link below the code check it out

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