Can't get any parts in the table

Hello, I am trying to make a block grab system that stacks blocks.

I currently have the grabbing blocks ready, but not the stacking. My approach to stacking is to insert the parts in a table and get the offset from the size total size of Y.

The problem is that I can not get any parts in the table, I am trying to insert parts into the table, but when I print the stackTable its completely empty even if i just insert a part into the table, and print it in the next line. (The last 3 lines)

How could I fix this? I am really stuck.

This is a local script if that helps.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local hum = char:WaitForChild("Humanoid")
local CanGrabBlock = true

--The part where stacking blocks will be stored
local StackTable = {}



local function Block(plr, block)
    print(StackTable)
    if CanGrabBlock == true then
        local offsetInformation = 0
        --Find Offset if there is any
        
        
        if #StackTable > 0 then
            for i, blockIterate : BasePart in StackTable do
                print(blockIterate)
                local add = blockIterate.Size.Y
                print(add)
                offsetInformation += add
            end
        else
            offsetInformation = 0
        end
        
        
        game.ReplicatedStorage.GrabEvents.GrabRequest:FireServer(plr, block, offsetInformation)
        uis.InputBegan:Connect(function(input, gameProcessedEvent)
            
            if input.KeyCode == Enum.KeyCode.T then
                game.ReplicatedStorage.GrabEvents.ReleaseRequest:FireServer(plr, block)
                wait(1)
                CanGrabBlock = true
      
         
            end
            
        end)
    end
end

game.ReplicatedStorage.GrabEvents.SendClient.OnClientEvent:Connect(function(plr, block)
    Block(plr, block)
    table.insert(StackTable, block)
end)

Is block an instance? If I’m correct, you can’t add instances to tables.

…What? You can literally add any datatype to tables?

My bad, I got confused with something.

Hello, you were too late to answer and I already solved it.

The problem was that I was sending information to client from the proximity prompt I was using, and when I was recieving the event I accidentally made an unnecessary variable “plr” in the Block function, that led to confusion of all sorts. The plr variable was actually the block itself. And because of the some really confusing variable naming, I missed it.

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