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 1 year 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)

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

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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!

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

Answer this question