Unable to access value from table

hey there! at the moment, when a remote event is fired and handled on the server I am unable to return a cashier object despite it being stored in a table in a module script.

module:

Register.ClaimedRegisters = {} -- [register] = player

...

function Register.ClaimRegister(player, register)
	Register.ClaimedRegisters[register] = player
end

server script:

OpenTipJarGUIEvent.OnServerEvent:Connect(function(player, tipJar)
	local register = tipJar.Parent
	local cashier = RegisterModule.ClaimedRegisters[register]

	if cashier then
		local assets = CashierTippingModule.PlayerAssets[cashier.UserId]

		if assets and #assets > 0 then
			OpenTipJarGUIEvent:FireClient(player, assets, cashier.Name)
		end
	else
		print("no cashier")
	end
end)

1 Like

Do you really need an entire function for that, vro? :v: :broken_heart:

Ever heard of contexts?
Table required by modulescript on a client ~= table on a server;
Its a 2 separate non replicatable to each other entities.
I also suggest dumbing down all of it and removing the module script entirely because you essentially use it just to store a table reference.

1 Like

that’s not the entire function nor the module I just shortened it down bc the rest is irrelevant In this case. so how else should I approach this?

Well firstly you need to understand what does run contextmeans.

This are essentially 2 separate entities for both server and client who have 2 separate table entities; althrough this modulescript may share same instance hash.

You can use an ObjectValue in the register to keep track of who’s currently assigned as cashier

okay thank you for that :slight_smile: much appreciated

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.