local other = {
attachment = massTax.StartMassTax.Attachment
}
print(other)
--this prints: {}
Can someone explain why the table is printing empty and give me a fix for it?
Thanks in advance.
local other = {
attachment = massTax.StartMassTax.Attachment
}
print(other)
--this prints: {}
Can someone explain why the table is printing empty and give me a fix for it?
Thanks in advance.
It shouldn’t return an empty table, something else is probably interfering with it. Could you show where the script is / more of your code?
The job of the code is to check if an AI is in a zone (a part called StartMassTax).
The reason I only showed a small snippet was because the table basically isolated in its code, but I do need it to fire to the server.
for i, v in massTax.StartMassTax:GetTouchingParts() do
if v.Parent.Name == "AI" and not table.find(currentlyTouching, v.Parent) then
print("npc alr in")
table.insert(currentlyTouching, v.Parent)
local npc = v.Parent
local other = {
attachment = massTax.StartMassTax.Attachment
}
print(other)
remotes.StealData:FireServer(npc, 2, "MassTax", nil, other)
end
end
And before firing to the server, it prints an empty table?
You most likely don’t have Log Mode off.
Look down at your output window, find the three horizontal dots on the far right at the top of it, make sure “Log Mode” is unchecked.
After doing that, you should be able to print tables and view them within output.
Without Log Mode disabled, the only way you’d be able to see what is inside of the table is by finding the length of it, by doing print(#table).
yes that’s correct, i’ve tried changing the contents of the table but it still doesn’t work.
my log mode is off, it dont think the problem is printing, I think it has to do with the code, because when I try to access it in the code, it throws an error that happens when trying to access something that is nil.
I just tried something, and found out when I put the code outside of a local function, the table printed, so I think it has to do with the function, but I’m not sure why, here’s the rest of the code if anyone could help.
local function MassTax()
local humrp = char.HumanoidRootPart
local currentlyTouching = {}
local massTax = FX.Meshes.MassTax:Clone()
massTax.Parent = char
massTax.PrimaryPart.CFrame = humrp.CFrame
for i, v in massTax.StartMassTax:GetTouchingParts() do
if v.Parent.Name == "AI" and not table.find(currentlyTouching, v.Parent) then
print("npc alr in")
table.insert(currentlyTouching, v.Parent)
local npc = v.Parent
local other = {
attachment = script.Parent
}
print(other)--this prints out nil
remotes.StealData:FireServer(npc, 2, "MassTax", nil, other)
end
end
end
UIS.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.R then
if not cds.massTax.onCD then
actionCD(5)
cds.massTax.onCD = true
local other = {
attachment = script.Parent
}
print(other) --this prints out the table
MassTax()
end
end
end)
Since you’re calling MassTax() in the InputBegan event, how about you pass the table as a parameter, then try printing it like that?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.