Sending tables from the server to the client

I’ve been trying to send tables from the server to the client and it hasn’t been working, any reason to that?

--//Server//--
fxhandler:FireAllClients("Tween", VFX, {
			TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out),
			{Transparency = 1, Size = Vector3.new(25,25,25)}
		})
--//Client//--
elseif a == "Tween" then
		local TweenServ = game:GetService("TweenService")
		TweenServ:Create(b, unpack(c)):Play()
	end

The error keeps returning as argument 2 is missing or nil.

Unpack should be assigned to multiple variables, what your script is doing right now is unpacking it and only getting the first item in the table (I think?)
This reply explains how unpack() works in more depth: How do I unpack this table? - #2 by goldenstein64

when you unpack a table like I did it unpacks all the values, i’ve tested it on the server fully and it works fine but just when I try and send this to the client it breaks.

1 Like

And does it unpack a table within a table? I don’t think I have ever used unpack() so I’m not sure. It’s a problem with the table/unpacking, though.

Yeah, i’ve tried everything now and whatever I do the client just can’t pick up the table for some reason.

Honestly it’s at this point if I were you I’d just put them in separate parameters instead of pulling your hair out trying to fix it, I think it’s to do with the fact unpack doesn’t separate the table’s items with a comma that the the tween creation wants to separate arguments.

I believe you have to use table.unpack(c, 1, #c)

1 Like

I believe just table.unpack(table) works.

that will unpack only the first index

1 Like

Ah I see, you’re right I just checked

I still get the same result from before " Argument 2 missing or nil"

Weird, maybe try this:

local TweenService = game:GetService("TweenService")
local TInfo = c[1]
local Properties = c[2]
TweenService:Create(b, TInfo, Properties):Play()

tl;dr

TweenService:Create(b, c[1], c[2]):Play()

Nope, I still get all of the same results as before.

maybe try printing c (30 limit)

It prints correctly for some reason but when I use the tween info.new and other things things it just doesn’t work.

Just got it to work actually, I just tried something new

--//Server//--
fxhandler:FireAllClients("Tween", VFX, {
			Info = {3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out},
			Goal = {Transparency = 1, Size = Vector3.new(45,45,45)}
		})
--//Client//--
	elseif a == "Tween" then
		local TweenServ = game:GetService("TweenService")
		TweenServ:Create(b, TweenInfo.new(table.unpack(c.Info)), c.Goal):Play()
	end

Was typing up the exact same thing :sweat_smile:

Haha, thanks for all your help!

1 Like