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

How can I make it so a certain team has different animations than the other teams?

Asked by 1 year ago

Hi, I want to create a 'Zombie" team which has all of the default animations ready to replace it. Problem is, I don't know how. I'd also like to make it so that this team specifically has a low walking speed. Can anyone help me on what I might need to do?

here's my code so far:

local Player = game:GetService("Players").Player1 local Team = game:GetService("Teams")["Zombie"]

if Player.Team == Team then

end

1 answer

Log in to vote
0
Answered by 1 year ago

The way you're going about this is bad since this is (presumably) a server script and you are directly referencing a player that may or may not exist when the code is running.

What you most likely want to do PlayerAdded event to detect when a player joins and assign them a team. Then you also want to hook the CharacterAdded event for each player to set the walkspeed on respawn (since otherwise it would reset when they die).

Here's the code you might want to use:

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 = 8 -- Change this to the walkspeed you want the zombie team to have. You can also add any other animations/effects after this point
    end
end

local function onPlayerAdded(player)
    -- Check if they already have a character (only happens in studio)
    if player.Character then
        onCharacterAdded(player.Character)
    end
    -- Listen for regular player spawns
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded) -- Make the playeradded function run every time a player joins
0
but how can i give them the animations? LunaticFETCH 5 — 1y
0
How would I give them the animations? It works, but no animations. LunaticFETCH 5 — 1y
Ad

Answer this question