Having trouble passing arguments through ClientEvents

I left Roblox for a while, for like 2 years, and I’ve forgotten about everything I knew about Lua.
I’m just trying to pass and argument through an event (very simple)
I learned java so its different not having like classes or types for objects. lua is weird fr

script.Parent.UpdateServers.OnClientEvent:Connect(function(list)
		print(#list)
end)
local list = {"1","2","3","5"}




script.Parent.UpdateServers.OnServerEvent:Connect(function()
	
	print("fired")
	
	script.Parent.UpdateServers:FireClient(list)
	
end)

Unable to cast value to Object

It prints “fired” but then it throws an error
I know the answer is gonna be something really easy but keep in mind I haven’t touched roblox studio in 2 years.

Make sure your First variable on the :FireClient() is the Player

When Firing on the Client: (Player, Var1, Var2, etc)

The Exception to this is :FireAllClients() which fires to all Players.

3 Likes

I believe this is because there is more than one argument sent along through client events, one is the actual player. (Player, actual data)

1 Like

Event:FireClient() requires a player variable so that the server knows which client it should fire the event on. For example:

script.Parent.UpdateServers:FireClient(player, list)

3 Likes

I realized I wanted to use FireAllClients()
Thank you

Other replies were also good

1 Like

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