CreateNewBoard function is not creating a board for player

Hello everyone, I am a scripter. I recently wrote a module script and decided to test it. However, during my tests, I kept getting the “board not found” error. Without adding proper checks, the module would just throw errors.

I reviewed the code countless times, tried fixing it over and over, but nothing seemed to work. I even asked three friends for help, but they couldn’t solve it either. AI suggestions just made it worse.

Can anyone help me?

After some debugging, it seems like the Board table isn’t being initialized for new players, like the creation is being skipped.

local Effects = {}
local Board = {}
local Players = game:GetService("Players")

local StandartLevel = 1
local StandartDuration = 5


function Effects.CreateBoard(Player)
	print(Player, Player.UserId)
	if not Player then
		print("Player not valid")
		return 
	end
	
	if Board[Player.UserId] then
		print("Board exists so cancelling to create")
		return 
	end
	
	Board[Player.UserId] = {
		["Burning"] = false
	}
	
	print(Effects)
	
	print("DEBUG ENDED")
end

function Effects.RemoveBoard(Player)
	if not Player then return end
	if not Effects[Player.UserId] then return end

	Effects[Player.UserId] = nil
end

function Effects.PrintBoard(Player)
	print(Board)
end





function Effects.Burning(Player, Level, Duration)
	print(Player, Level, Duration)
	if not Player or not Player:IsA("Player") then 
		print("Plr is invalid cancelling")
		return 
	end
	
	if not Board[Player.UserId] then
		print("Board doesn't exists")
		return
	end
	
	if Board[Player.UserId].Burning then 
		print("Plr already being burned")
		return 
	end
	Board[Player.UserId].Burning = true

	Level = Level or StandartLevel
	Duration = Duration or StandartDuration

	local RootPart = Player.Character and Player.Character:FindFirstChild("HumanoidRootPart")
	local Humanoid = Player.Character and Player.Character:FindFirstChild("Humanoid")

	if not RootPart or not Humanoid then
		print("RootPart or Humanoid is not found")
		Board[Player.UserId].Burning = false
		return
	end

	local Fire = Instance.new("Fire")
	Fire.Size = 5
	Fire.Heat = 10
	Fire.Parent = RootPart

	local StartTime = tick()

	while tick() - StartTime <= Duration do
		Humanoid:TakeDamage(Level)
		task.wait(1)
	end

	Fire:Destroy()
	Board[Player.UserId].Burning = false
	print("Burning finished")
end

return Effects

The server script that calling CreateNewBoard function:

local Players = game:GetService("Players")
local Effects = require(game:GetService("ReplicatedStorage").Assets.Modules.Effects)

Players.PlayerAdded:Connect(function(Plr)
	Plr.CharacterAdded:Connect(function(Chr)
		Effects.CreateBoard(Plr)
		print("Created board for plr")
		if Chr.Parent == workspace then
			Chr.Parent = workspace.Players.Spectating
		end
	end)
end)

Players.PlayerRemoving:Connect(function(Plr)
	Effects.RemoveBoard(Plr)
end)
1 Like

In Effects.CreateNewBoard, you add the player to the Board table, but Effects.RemoveBoard checks the Effects table and not the Board table

Where do you print board not found?

My friends told me to try adding it to the Effects table. I forgot to fix it again. Thanks for telling me

This is where i print board doesnt exists

Please send the new code snippet