PlayerValues table module not connecting to server/client

I’m making a block building game and I’m running into trouble with letting the player change the properties of the block they want to place. The way its handled is that a UI will affect a set of properties in a table from a module and uses functions from it to set it to the player.

The client SHOULD be getting it to send to the server, but it’s not working for some reason.

https://gyazo.com/e5540c48e8881c1e5e7cabd2e10dea78

local function ApplyBlockProperties(newBlock, properties)
	for propName, value in pairs(properties) do
		if typeof(value) == "boolean" then
			if newBlock[propName] ~= nil then
				local success, err = pcall(function()
					newBlock[propName] = value
				end)
				if not success then
					warn("[ApplyBlockProperties] Failed to set", propName, err)
				end
			end
		elseif typeof(value) == "number" then
			if newBlock[propName] ~= nil then
				local success, err = pcall(function()
					newBlock[propName] = value
				end)
				if not success then
					warn("[ApplyBlockProperties] Failed to set", propName, err)
				end
			end
		end
	end
end
  • Which is called like this
	if properties then
		ApplyBlockProperties(newBlock, properties)
	end
	

The client gets the values like this:

local moduleValues = BlockPropertiesModule.GetProperties(player)
local PlayerProperties = {}

for categoryName, props in pairs(BlockPropertiesModule) do
	if type(props) == "table" then
		for _, prop in ipairs(props) do
			if moduleValues[prop.Name] ~= nil then
				PlayerProperties[prop.Name] = moduleValues[prop.Name]
			else
				PlayerProperties[prop.Name] = prop.Default
			end
		end
	end
end
  • Which then sends it to the server like this:
	local propertiesToSend = {}
	for k,v in pairs(PlayerProperties) do
		propertiesToSend[k] = v
	end

	print("[DEBUG] Sending Properties:", propertiesToSend)
	PlaceBlock:FireServer(worldPos, color, material, shape, rotationX, rotationY, propertiesToSend)

I’m stuck and sorry if this is too hard to read or described poorly. I’m trying my best to fix this crap. Please give me feedback, thank you!

1 Like

i would recommend using a database to store the block properties in the server- i am using this myself and it works like a charm, i think the easiest way is to use Firebase, especially if your game is multiplayer. i also recommend using the official Roblox Studio RemoteEvents to send the data between server-side and client-side.
i hope that helps you out

1 Like