Why this script dosent work?

The problem is that the spawn objects are in the script. they have to be in the workspace to be able to be touched. Make them anchored on. Uncancollidable, cantouch and canquery off. Make the spawns transparent and then place them in the workspace.

local Players = game:GetService("Players")
local PlayerNumber = script.Parent:FindFirstChild("PlayerNumber")

local Spawns = game.Workspace:FindFirstChild("Spawns")

local PlayerTouched = {}

for _, spawnLocation in ipairs(Spawns) do
	spawnLocation.Touched:Connect(function(otherPart)
		local character = Players:GetPlayerFromCharacter(otherPart.Parent)
		if character and not PlayerTouched[character.Name] then
			PlayerTouched[character.Name] = character.Name
			PlayerNumber.Value = PlayerNumber.Value + 1
			local humanoid = character:FindFirstChild("Humanoid")
			if humanoid then
				humanoid.Died:Connect(function()
					PlayerTouched[character.Name] = nil -- Remove player from the list when they die
					PlayerNumber.Value = PlayerNumber.Value - 1
					print("ded")
				end)
			end
		end
	end)
end

Makes sense, but what if op place the script on workspace as well?

still it didn’t work, and i still don’t see and error

Where do you put the spawn objects and the script?

i put this script in the workspace

this is the reason it doesnt work. consider changing it to this

local Players = game:GetService("Players")
local PlayerNumber = script.Parent:FindFirstChild("PlayerNumber")

local Spawns = game.Workspace:FindFirstChild("Spawns")

local PlayerTouched = {}

for _, spawnLocation in Spawns:GetChildren() do
	spawnLocation.Touched:Connect(function(otherPart)
		local character = Players:GetPlayerFromCharacter(otherPart.Parent)
		if character and not table.find(PlayerTouched, character.Name) then
            table.insert(PlayerTouched, character.Name)
			PlayerNumber.Value = #PlayerTouched
			local humanoid = character:FindFirstChild("Humanoid")
			if humanoid then
				humanoid.Died:Connect(function()
					table.remove(PlayerTouched, table.find(PlayerTouched, character.Name)) -- Remove player from the list when they die
					PlayerNumber.Value = #PlayerTouched
					print("ded")
				end)
			end
		end
	end)
end

Guys, this is where the problem are.

Can you explain what is the reason?

Well, first of all, did it work?

local Players = game:GetService("Players")
local PlayerNumber = script.Parent:FindFirstChild("PlayerNumber")

local Spawns = script.Parent:FindFirstChild("Spawns"):GetChildren()

local PlayerTouched = {}

for _, spawnLocation in ipairs(Spawns) do
	spawnLocation.Touched:Connect(function(otherPart)
		local character = Players:GetPlayerFromCharacter(otherPart.Parent)
		if character and not PlayerTouched[character.Name] then
			PlayerTouched[character.Name] = character.Name
			PlayerNumber.Value = PlayerNumber.Value + 1
			local humanoid = character:FindFirstChild("Humanoid")
			if humanoid then
				humanoid.Died:Connect(function()
					PlayerTouched[character.Name] = nil -- Remove player from the list when they die
					PlayerNumber.Value = PlayerNumber.Value - 1
					print("ded")
				end)
			end
		end
	end)

This is the original code by op, LinuxKat code is modified and it is wrong as you said.

i have a error that said

Workspace.Survival Mode.WaveSystem:109: attempt to index nil with ‘GetChildren’

alrighty then
try this

local Players = game:GetService("Players")
local PlayerNumber = script.Parent:WaitForChild("PlayerNumber", 30)

local Spawns = script.Parent:WaitForChild("Spawns", 30):GetChildren()

local PlayerTouched = {}

for _, spawnLocation in Spawns do
	spawnLocation.Touched:Connect(function(hit)
		local character = Players:GetPlayerFromCharacter(hit.Parent)
		if character and not table.find(PlayerTouched, character.Name) then
			table.insert(PlayerTouched, character.Name)
			PlayerNumber.Value = #PlayerTouched
			local humanoid = character:FindFirstChildWhichIsA("Humanoid")
			if humanoid then
				humanoid.Died:Connect(function()
					table.remove(PlayerTouched, table.find(PlayerTouched, character.Name)) -- Remove player from the list when they die
					PlayerNumber.Value = #PlayerTouched
					print("ded")
				end)
			end
		end
	end)

can you please show the explorer

No difference than my solution

And it does not work

it didnt work i tried it oof kghjkgjgh

@Blue0utline can you create a module script in serverscriptservice named ‘PlayerTouched’

Yes thats what I said. Also have you tried rem’s code?

For what? Add a reason why you want him to add module script inside ServerScriptService so he can understand what you are gonna do.

You don’t need table. … although it is nicer

there should be a script in startercharacterscripts that can remove the character’s name from tables inside the module playertouched returns

modulescript looks like this

local spawns = {}

for _, v in workspace:WaitForChild("Spawns"):GetChildren() do
    spawns[v] = {} --separate PlayerTouched tables
end

return spawns