Module Script Not Working (No Errors Too)

Alright so here is my code.

main script

wait(2)
local Players = game.Players
local ReplicatedStorage = game.ReplicatedStorage
local ServerStorage = game.ServerStorage
local ChangeText = game.ReplicatedStorage.ChangeText
local InGame = game.ServerStorage.Values.InGame
local PlayersLeft = game.ServerStorage.Values.PlayersLeft
local Functions = require(script:WaitForChild("function"))

while true do
	ChangeText:FireAllClients("Waiting for 2 players")
	repeat wait() until #game.Players:GetPlayers() >= 2
	ChangeText:FireAllClients("Starting")
	wait(7)
	Functions.SetPlayersLeftValue()
	
	
	for _, player in pairs(Players:GetPlayers()) do
		Functions.SpawnPlayerValue(player, false)
	end
	
	Functions.resetKills()
	
	wait(3)
	
	ChangeText:FireAllClients("Loading Map")
	
	wait(3)
	
	Functions.TeleportPlayer()
	
	ChangeText:FireAllClients("")
	
	wait(5)

	Functions.GetPlayerKnifesAndGiveItToThem()
	
	repeat wait() until game.ServerStorage.Values.PlayersLeft.Value == 1
	
	ChangeText:FireAllClients("Game Over!")
	
	wait(7)
	
	Functions.KillPlayers()
end

MODULE SCRIPT

local Functions = {}

function Functions.resetKills()
	for _, player in pairs(game.Players:GetPlayers()) do
		player.KillsThatRound.Value = 0
	end
end

function Functions.checkSpawned(player)
	if player.SpawnedInMap.Value == true then
		return true
	elseif player.SpawnedInMap.Value == false then
		return false
	end
end

function Functions.SpawnPlayerValue(player, value)
	player.SpawnedInMap.Value = value
end



function Functions.TeleportPlayer()
	for _, player in pairs(game.Players:GetPlayers()) do
		local SpotsToSpawnIn = {}
		local TheirSpot
		for i, v in pairs(workspace.SpawnPoints["2"]:GetChildren()) do
			table.insert(SpotsToSpawnIn, v)
		end
		for i, v in pairs(SpotsToSpawnIn) do
			print(v)
			local number = SpotsToSpawnIn[math.random(1, #SpotsToSpawnIn)]
			TheirSpot = number
			print(number)
		end
		if player.Character == nil then
			repeat wait() until player.Character ~= nil 
			player.Character.HumanoidRootPart.CFrame = TheirSpot.CFrame
		else
			player.Character.HumanoidRootPart.CFrame = TheirSpot.CFrame
		end
	end
end

function Functions.GetPlayerKnifesAndGiveItToThem()
	for _, player in pairs(game.Players:GetPlayers()) do
	local CurrentKnifeValue = player.CurrentKnifeValue.Value
	local TheirKnife = game.ServerStorage.Knifes:FindFirstChild(CurrentKnifeValue)
	if TheirKnife ~= nil then
		local Cloned = TheirKnife:Clone()
		Cloned.Parent = player.Backpack
	end
end
	
	
	function Functions.SetPlayersLeftValue()
		print("s")
		for _, v in pairs(game.Players:GetPlayers()) do
			game.ServerStorage.Values.PlayersLeft.Value = game.ServerStorage.Values.PlayersLeft.Value + 1
			v.inGame.Value = true
		end
	end
	
function Functions.KillPlayers()
		for _, v in pairs(game.Players:GetPlayers()) do 
			v.Character.Humanoid.Health = 0
		end
	end
end
	
return Functions

DONT MIND BAD CODE
Also, I know some things don’t have a need to be in a module script, but I am just testing things.

1 Like

As far as I can tell from reviewing your code everything should be functional.

The only problem I see is this function inside the module:

Unless this was just an error when copy-pasting the code, you forgot the end that closes this function.

Are you testing solo? If so that explains it.

No I am not. I am testing with 2 people and the while true loop doesn’t even start.

this the actual name or not, check console for warning on waitforchild.

I noticed that it was wrong. But now I am getting

Requested module experienced an error while loading 

Check the modules for errors now, is the functions module always a child of the script you are calling it from? Because if its always a child there really isnt a reason to use waitforchild.