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
end
end
local function onPlayerAdded(player)
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
2 comments
but how can i give them the animations?
How would I give them the animations? It works, but no animations.