How do access a module instance outside of player added method?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am attempting to make my data save module save data when they leave but cant access the module instance from outside the method and i dont know if my current method is the best way

local DataClass = require(game:GetService("ServerScriptService"):WaitForChild("Classes").DataClass)

game.Players.PlayerAdded:Connect(function(player)
	local PlayerData = DataClass.new(player)
	
	PlayerData:CreateData("Points", 15)
	PlayerData:CreateData("Level", "Level3")
	
	PlayerData:LoadData()

	game.Players.PlayerRemoving:Connect(function(player)
		PlayerData:SaveData()
	end)
end)

First of all you need to do this!

local DataClass = require(game:GetService("ServerScriptService"):WaitForChild("Classes").DataClass)

game.Players.PlayerAdded:Connect(function(player)
	local PlayerData = DataClass.new(player)
	
	PlayerData:CreateData("Points", 15)
	PlayerData:CreateData("Level", "Level3")
	
	PlayerData:LoadData()
end)

game.Players.PlayerRemoving:Connect(function(player)
	PlayerData:SaveData()
end)

I cant do that, PlayerData is only accessible inside the player added event so I cant reference it outside of the player added event

You can simply change PlayerData into an array (table) external to the Added-listener and index it by
Player.UserId