Unpack Limit Fix

I’m getting this error when unpacking a table (~ 8k members)

too many results to unpack

How do i fix this?

1 Like

What are you trying to do that has more than 8,000 entries to unpack? Sounds like your table is trying to a lot more than it should.

1 Like

every part on the map thats collide able

Maybe we can try to find a different way to get what you are doing to work. What are you using unpack for?

Raycast with whitelist/ignorelist

Don’t you need to pass in a table of instances to ignore, not each instance as a parameter?

Could you explain a bit more of what exactly you are using unpack for? Maybe share some code. I think we could find another method.

local TestRay = Ray.new(CF1.p,(CF2.p-CF1.p))
local Hit,Pos = workspace:FindPartOnRayWithWhitelist(
    TestRay,
    GetExtCache.Init(
        {workspace.Terrain,workspace.Ignore.Walls,workspace.Ignore["Supply Drop"]},
        ClientModules.Bullets.GetCollideableMapCache()
    )					
)

--GetExtCache module
local module = {}

module.Init = function(curTable, cache)
	local new = {
		unpack(curTable),
		unpack(cache)
	}
	return new
end

return module

This won’t work the way you think it does. It’ll only put the first element of curTable in.

how do i put everything all in the same table?

Make a new buffer table and loop over both tables and insert.

lol that drops me down to 30 fps bc im doing it all on a loop

You’d be a lot better off just looping over FindPartOnRayWithBlacklist, checking if the hit is something you don’t want, adding it to the blacklist, and repeating until it’s either not collidable or nil.

This is some similar code I have. I update a blacklist table every time the hit is something I don’t want (the Raycast module just ends up calling FindPartOnRayWithBlacklist).

2 Likes

if you add an object to collectionservice on the client and its a client only object, what happens on the server?

Nothing.

Any tags added by the server to an object will replicate to clients. Clients that add tags to objects will only have those tags accessible by themselves. If the server at any time modifies the tags of an object, the client’s set tags on that object will be overwritten and they will be provided with the ones that the server acknowledges. Think of tags like the values of ValueObjects.

I think you are thinking about this wrong if you ever need to put 8000 objects in your whitelist for FindPartOnRayWithWhitelist. Just passing 8000 objects over the Lua -> C++ reflection layer to this function will probably have bad performance. Raycasting with a whitelist includes all descendants of the passed objects, so are you able to put all the collidable workspace parts in 1 model?

3 Likes

Yeah when i design my new system thats what ima do