Tile info doesnt save to a table

  1. What do you want to achieve?
    A NES tile system like, well the NES.

  2. What is the issue?
    My issue is that the tiles are not being added to the tile ROM even thou I call table.insert() on the tile table (on a module script) it isn’t adding anything

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I tried changing values, printing for debbuging and other things like that,
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The server loads tiles into the players POV by passing it through replicated storage, this works, the tile data is on a module script inside Replicated storage too, only accesed by client, coloring of tiles work, but the tile’s data isnt added to the tile data table (or what seems like it)

EXAMPLE OF WHAT A TILE SHOULD LOOK LIKE!
0: the darkest color in the pallet
1: middle color on the pallet
2: lightest color on the pallet
3: background color (one color only)

pallets work fine! Just rendering the tiles is wrong (the colors load just the black and white

[1] = {
	2,1,0,3,3,3,3,3,
	3,3,3,3,3,3,3,3,
	3,3,3,3,3,0,3,3,
	3,3,1,3,3,3,3,3,
	3,3,2,3,3,3,3,3,
	3,3,3,3,3,3,3,3,
	3,0,3,3,3,3,3,0,
	3,3,3,3,0,3,3,3,
}

HERES WHAT MODULE CONTAINING THE TILE DATA LOOKS LIKE

local charRom = {}
local bgTileTable = {
	--[[
	[999] = { -- blank tile
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
		3,3,3,3,3,3,3,3,
	},
	]]
}
local spriteTable = {
	
}
function charRom.addTileData(info) -- what i dont understand, because its printing but nothing gets added?
	print(info)
	table.insert(bgTileTable,info)
	
end
function charRom.getSpecificBgTileByIndx(indx)
	return bgTileTable[indx]
end
function charRom.getBgRomData()
	return bgTileTable
end
function charRom.getSpecificSpriteData()
	-- to be worked on!
end
function charRom.getSpriteRomData()
	-- to be worked on!
end
return charRom

*** HERE IS THE TILE PIXELART EDITOR LOOKS LIKE (drawing works and the info is correct) but doesnt seem to be added to the tile table ;/ ***

local selClr = 3
local tileDrawArea = script.Parent.tileDrawArea
local pxSize = 40
local pxX = 0
local pxY = 0
local RAM = require(game.ReplicatedStorage.RAM)
local charROM = require(game.ReplicatedStorage.charROM)
local colors = require(game.ReplicatedStorage.nesColors)

local grayScaleIndex = {
	Color3.fromRGB(0, 0, 0),       -- 1
	Color3.fromRGB(68, 68, 68),    -- 2
	Color3.fromRGB(118, 118, 118), -- 3
	Color3.fromRGB(255, 255, 255)  -- 4 (background)
}
local pxIndex = 0
for i=1,8 do
	for ii=1,8 do
		pxIndex += 1
		local pixelBtn = Instance.new("TextButton",tileDrawArea.tileStart)
		pixelBtn.Text = ""
		pixelBtn.Position = UDim2.new(0,pxX * pxSize,0,pxY * pxSize)
		pixelBtn.Size = UDim2.new(0,pxSize,0,pxSize)
		pixelBtn.BorderSizePixel = 0
		pixelBtn.BackgroundColor3 = Color3.fromRGB(255,255,255)
		pixelBtn.Name = tostring(pxIndex)
		pxX += 1
		pixelBtn:SetAttribute("palletIndx",3)
		pixelBtn.MouseButton1Click:Connect(function()
			script.paint:Play()
			pixelBtn:SetAttribute("palletIndx",selClr)
			pixelBtn.BackgroundColor3 = grayScaleIndex[selClr+1] -- finds right color on list
		end)
	end
	pxX = 0
	pxY += 1
end
pxIndex = 0
for i,v in pairs(grayScaleIndex) do
	local pallOpt = script.palletOption:Clone()
	pallOpt.main.clrBtn.BackgroundColor3 = v
	pallOpt.main.palletClrLabel.Text = pallOpt.main.palletClrLabel.Text .. tostring(i - 1)
	pallOpt.main.clrBtn.MouseButton1Click:Connect(function()
		selClr = i - 1
	end)
	pallOpt.Parent = script.Parent.tileDrawArea.clrOptions
end
script.Parent.tileDrawToggle.MouseButton1Click:Connect(function()
	script.Parent.tileDrawArea.Visible = not script.Parent.tileDrawArea.Visible
	script.Parent.Parent.mainScreen.Enabled = not script.Parent.Parent.mainScreen.Enabled
end)
script.Parent.addTileBtn.MouseButton1Click:Connect(function()
	local newTileData = {}
	local tileSrtr = script.Parent.tileDrawArea.tileStart
	for i=1,64 do
		local v = tileSrtr:FindFirstChild(tostring(i))
		if v:IsA("TextButton") then
			if v:GetAttribute("palletIndx") then
				table.insert(newTileData,v:GetAttribute("palletIndx"))
			end
		end
	end
	if #newTileData == 64 then
		charROM.addTileData(newTileData)
	else
		warn("Failed to pack data into charROM!",newTileData)
	end
end)

From what i could gather, the tile info goes to the function (because the print works) but it doesnt get added to the list?

all of the functions are called by the client btw!

Please, if you need any more info, tell me. Im soo confused cuz it used to work perfectly :frowning: ( with a offset )

CLARIFICATION EVERYTHING IS RUN ON CLIENT

How are you checking the contents of bgTileTable?

by calling on the client

local charRom = require(game.ReplicatedStorage.charRom)
local allTiles = charRom.getBgRomData()

allTiles will then have the contents of charROM :slight_smile:

The problem is, charRom on the server is a different table from the charRom on the client, even if it is in replicated storage, as that would be a hell of a security problem.
In order to access the data set on the server you gotta use RemoteEvents to pass it to the client.

sorry for late reply, i was eating but the charROM is on the replicated storage and im doing a NES thing so hacking isnt a problem, but why is it not adding it in if its in rep store

If it’s fully on the client then i have no idea what’s wrong, but if you’re modifying it on the server just know that it won’t affect the one on the client.

1 Like

How do you know the table doesn’t contain anything?

I can’t see anything that would cause the table to be empty, so I’m wondering if there’s a logical bug somewhere else when you use it. If you print bgTileTable in your module after updating it, it should show it changing, right? table.insert doesn’t fail silently.

local charRom = require(game.ReplicatedStorage.charRom)
local allTiles = charRom.getBgRomData()
print(allTiles)

it prints

{}

The only issue I can think about this is that table.insert does it on the server, and if your trying to access it from the client it just can’t.

1 Like

nope, the module script is ON replicated storage, and other stuff like pallets are successfully inserted into their own respective module scripts and work correctly when rendering into the custom NES screen so i dont get it

It is on ReplicatedStorage but I don’t think the actual values you add are replicated between Client to Server

1 Like

there is never any client to server comms in the game, the only comms are for the server to render the screen because its faster to render the 8x8 tile pixels that fit of the NES screen in the server to the client then the client recieves the screen, beside that no other server comms happen!

Just to double check, this code is ran on the client, right?

yes it is,
that fact is now clarified on the post itself :slight_smile:

1 Like

Well, I’m really grasping at straws here. Have you tried doing bgTileTable[#bgTileTable + 1] = info instead of using table.insert? And you’ve tried printing bgTileTable from inside of charRom.addTileData..?

Does charRom.getSpecificBgTileByIndx give anything?

Where does this server communication happen?

i am using table.insert AND NO SERVER COMMS HAPPEN WHILE ATTEMPTING TO INSERT DATA INTO THE TILE DATA, ITS ALL ON CLIENT!!

Can you send a copy of the place for me to mess around? The best way for me to find out is checking the structure of the scripts and code myself, I really wanna find out what is going wrong, if not no problem.

can i just send relevant script locations/scripts?
im not comfortable with sharing place files due to stealing :confused:

Sorry for being so late, can you make a test place with just the relevant scripts all on the same place as in the original?

1 Like