Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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)

1if plr.Team == Team then
2    character:WaitForChild("Humanoid").WalkSpeed = 11
3 
4end

end

local function onPlayerAdded(player)

1if player.Character then
2    onCharacterAdded(player.Character)
3end
4 
5player.CharacterAdded:Connect(onCharacterAdded)

end

Players.PlayerAdded:Connect(onPlayerAdded)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Check this out!

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

01local Teams = game:GetService("Teams")
02local Team = Teams:WaitForChild("Zombie")
03 
04Team.PlayerAdded:Connect(function(newTeammate)
05    local character = newTeammate.Character or newTeammate.CharacterAdded:Wait()
06    local humanoid = character:WaitForChild("Humanoid")
07    local animator = humanoid:WaitForChild("Animator")
08 
09    humanoid.WalkSpeed = 11
10 
11    for _, playingTrack in ipairs(animator:GetPlayingAnimationTracks()) do
12        playingTrack:Stop(0)
13    end
14 
15    local animateScript = character:WaitForChild("Animate")
View all 21 lines...

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

0
This does nothing. LunaticFETCH 5 — 2y
0
Is this a local script and does it go in serverscriptservice, or startercharacterscripts or maybe starterplayerscripts? LunaticFETCH 5 — 2y
0
it's a normal script in serverscriptservice T3_MasterGamer 2189 — 2y
0
if it still doesn't work i put a link below the code check it out T3_MasterGamer 2189 — 2y
Ad

Answer this question