My Script wont work

try this, you should get an error after this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

if rng == 1 then
	game.Workspace:WaitForChild("ZombieSound"):Play()
	local zombiesky = ReplicatedStorage:WaitForChild("RedSky"):Clone()
	Lighting:ClearAllChildren()
	zombiesky.Parent = Lighting
	
	game.Workspace:WaitForChild("zombiestart"):Play()
	
	for i, v in pairs(Players:GetPlayers()) do
		if v.Team == Teams.Zombies then
			local inventory = v.Backpack
			
			for i,h in pairs(inventory:GetChildren()) do
				if h:IsA("Tool") then
					h:Destroy()
				end
			end
			
			for i, h in pairs(v.Character:GetChildren()) do
				if h:IsA("Tool") then
					h:Destroy()
				end
			end
			
			task.wait(1.6)
			
			local zombiestuff = ReplicatedStorage:WaitForChild("ZombieStuff")
			
			local zombiehead = zombiestuff:WaitForChild("ZombieHead"):Clone()
			local zombieyell = zombiestuff:WaitForChild("zombiesound"):Clone()
			local clawtool = zombiestuff:WaitForChild("Claw"):Clone()
			
			clawtool.Parent = v.Backpack
			zombieyell.Parent = v.Character
			zombiehead.Parent = v.Character:WaitForChild("Head")
			
			if v.Character:FindFirstChildOfClass("Shirt") then
				v.Character:FindFirstChildOfClass("Shirt"):Destroy()
			end
			
			if v.Character:FindFirstChildOfClass("Pants") then
				v.Character:WaitForChild("Pants"):Destroy()
			end

			task.spawn(function()
				local shirt = Instance.new("Shirt")
				shirt.ShirtTemplate = "rbxassetid://15947510"
				shirt.Parent = v.Character

				local pant = Instance.new("Pants")
				pant.PantsTemplate = "rbxassetid://7156230"
				pant.Parent = v.Character
			end)

			spawn(function()
				for i,b in pairs(zombiestuff:WaitForChild("ZombieMeshes"):GetChildren()) do
					local zombiemesh = b:Clone()
					zombiemesh.Parent = v.Character
				end
				
				while true do
					task.wait(3)
					zombieyell:Play()
				end
			end)

			pcall(function()
				v.Character:WaitForChild("IsZombie").Value = true
				v.Character:WaitForChild("Humanoid").Health = v.Character:WaitForChild("Humanoid").Health + 50
				v.Character:WaitForChild("ACS_Client"):WaitForChild("Stances"):WaitForChild("Mobility").Value += 5
			end)
		end
	end
end

no errors ----------------------------------------------

The script works for me, What is the full script?

local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local rng = math.random(1,1)
if rng == 1 then
	game.Workspace:WaitForChild("ZombieSound"):Play()
	local zombiesky = ReplicatedStorage:WaitForChild("RedSky"):Clone()
	Lighting:ClearAllChildren()
	zombiesky.Parent = Lighting

	game.Workspace:WaitForChild("zombiestart"):Play()

	for i, v in pairs(Players:GetPlayers()) do
		if v.Team == Teams.Zombies then
			local inventory = v.Backpack

			for i,h in pairs(inventory:GetChildren()) do
				if h:IsA("Tool") then
					h:Destroy()
				end
			end

			for i, h in pairs(v.Character:GetChildren()) do
				if h:IsA("Tool") then
					h:Destroy()
				end
			end

			task.wait(1.6)

			local zombiestuff = ReplicatedStorage:WaitForChild("ZombieStuff")

			local zombiehead = zombiestuff:WaitForChild("ZombieHead"):Clone()
			local zombieyell = zombiestuff:WaitForChild("zombiesound"):Clone()
			local clawtool = zombiestuff:WaitForChild("Claw"):Clone()

			clawtool.Parent = v.Backpack
			zombieyell.Parent = v.Character
			zombiehead.Parent = v.Character:WaitForChild("Head")

			if v.Character:FindFirstChildOfClass("Shirt") then
				v.Character:FindFirstChildOfClass("Shirt"):Destroy()
			end

			if v.Character:FindFirstChildOfClass("Pants") then
				v.Character:WaitForChild("Pants"):Destroy()
			end

			task.spawn(function()
				local shirt = Instance.new("Shirt")
				shirt.ShirtTemplate = "rbxassetid://15947510"
				shirt.Parent = v.Character

				local pant = Instance.new("Pants")
				pant.PantsTemplate = "rbxassetid://7156230"
				pant.Parent = v.Character
			end)

			spawn(function()
				for i,b in pairs(zombiestuff:WaitForChild("ZombieMeshes"):GetChildren()) do
					local zombiemesh = b:Clone()
					zombiemesh.Parent = v.Character
				end

				while true do
					task.wait(3)
					zombieyell:Play()
				end
			end)

			pcall(function()
				v.Character:WaitForChild("IsZombie").Value = true
				v.Character:WaitForChild("Humanoid").Health = v.Character:WaitForChild("Humanoid").Health + 50
				v.Character:WaitForChild("ACS_Client"):WaitForChild("Stances"):WaitForChild("Mobility").Value += 5
			end)
		end
	end
end```

this isn’t what I wanted, I want it to be for the red team not, team.zombies

I changed it to red team, and it still doesn’t work

The if statement isn’t running I’m pretty sure

You don’t even need :FindFirstChild. Use dot operator. If something that should be there (like ZombieStuff folder) isn’t there, error will tell you right away where the problem is.

I cleaned the code from waitforchild as much as I can. Hopefully it will help to unserstand where it is okay to use and where it isn’t.

But the problem, however, is not really in this code. If it is a servers-side code, it will run before client is even connected, even in studio.

Try to add game:GetService("Players").PlayerAdded:Wait() before rng check.
If this code runs mid-game it shouldn’t be a problem, but in this specific case it may be.

local RepStorage = game:GetService("ReplicatedStorage")
local Lighting = game:GetService("Lighting")

local ZombieStuff = RepStorage.ZombieStuff
local WorkspaceZombieSound = workspace.ZombieSound
local Zombiestart = workspace.zombiestart
local ZombieSkyOrig = RepStorage.RedSky

local rng = math.random(1,1)

if rng == 1 then
	WorkspaceZombieSound:Play()
	local zombiesky = ZombieSkyOrig:Clone()

	zombiesky.Parent = Lighting
	Zombiestart:Play()

	for i,v in pairs(game:GetService("Players"):GetPlayers()) do
		print(v.Name.."'s team color is: "..tostring(v.TeamColor))
		if v.TeamColor == BrickColor.new("Bright red") then
			print("IT'S A ZOMBIE!!!")
			
			local Character = v.Character
			if not Character then
				print("... or not. Sadly, "..v.Name.." doesn't have a character at the moment.")
				continue --continue to next iteration (next player) if this one got no character
			end
			
			local Humanoid = Character:FindFirstChild("Humanoid")
			if Humanoid then
				Humanoid:UnequipTools()
			end
			
			-- Character's tool move to backpack instantly, we wait just for .Unequipped events to fire
			game:GetService("RunService").Heartbeat:Wait()
			
			local inventory = v.Backpack
			for i,h in pairs(inventory:GetChildren()) do
				if h:IsA("Tool") then
					h:Destroy()
				end
			end
			
			local zombiehead = ZombieStuff.ZombieHead:Clone()
			zombiehead.Parent = Character:FindFirstChild("Head")
			local zombieyell = ZombieStuff.zombiesound:Clone()
			zombieyell.Parent = Character.PrimaryPart --needs to be paranted to a part to be directional
			local clawtool = ZombieStuff.Claw:Clone()
			clawtool.Parent = v.Backpack
			
			-- Character may not have shirt, we need to check for that and if it isn't there just then continue
			local shirt = Character:FindFirstChild("Shirt")
			if shirt then
				shirt:Destroy()
			end
			local pants = Character:FindFirstChild("Pants")
			if pants then
				pants:Destroy()
			end

			task.spawn(function()
				-- not sure if it's even working
				local shirt = Instance.new("Shirt")
				shirt.ShirtTemplate = "rbxassetid://15947510"
				shirt.Parent = Character

				local pant = Instance.new("Pants")
				pant.PantsTemplate = "rbxassetid://7156230"
				pant.Parent = Character
			end)

			task.spawn(function()
				for i,b in pairs(ZombieStuff.ZombieMeshes:GetChildren()) do
					-- won't work either
					local zombiemesh = b:Clone()
					zombiemesh.Parent = Character
				end

				while true do
					task.wait(3)
					zombieyell:Play()
				end
			end)

			Character:WaitForChild("IsZombie").Value = true
			Character:WaitForChild("Humanoid").Health = v.Character:WaitForChild("Humanoid").Health + 50
			Character:WaitForChild("ACS_Client"):WaitForChild("Stances"):WaitForChild("Mobility").Value += 5
		end
	end
end

nothing changed, it doesn’t work still

the sound stuff works like, the music and skybox but anything with the if statement doesn’t work

so if we fix the if statement the rest of the code will probably work

Well, it also takes some time to spawn a character and assign player to a team.
You can try to put this before rng check for test purposes.

local test_check = false
game:GetService("Players").PlayerAdded:Connect(function(plr)
	repeat wait() until (plr.Character) and (plr.TeamColor == BrickColor.new("Bright red"))
	test_check = true
end)
repeat wait() until test_check

wouldn’t u wait for testcheck to be true

also that fixed it --------------------------

gonna test with 4 people to see if it actually works

All it does is just forces script to wait until there is a player, with a character, in a zombie team.
Without this check whole script was executing before there is even a single character that is eliglible for zombiefication.
So if you instead just run your code every N seconds then you don’t need it at all.

I will start using that method more

also I’ll send the finished product

2022-07-30 06-12-39 after all players ready up there is a chance for the zombie easter egg