I’m experiencing with the BitBuffer module from:
https://dekkonot.github.io/bitbuffer/ / BitBuffer Documentation
And I tried to write the example use (found on Writing - BitBuffer Documentation) with kind of success, but it won’t let me write it to a ModuleScript source. This is basically the script:
local data = {
name = "John Doe",
health = 100,
maxHealth = 100,
points = 10,
position = {
x = 10.55915,
y = -15.2222,
},
bossesKilled = { true, false, true },
}
local BitBuffer = require(game.ServerStorage.BitBuffer) -- The BitBuffer should be required here.
local buffer = BitBuffer()
buffer.writeString(data.name)
buffer.writeUInt16(data.health) -- This is assuming someone's health will get above 255 but stay below 32,767
buffer.writeUInt16(data.maxHealth)
buffer.writeUInt16(data.points) -- Also assuming someone's points will stay rather low
buffer.writeFloat32(data.position.x)
buffer.writeFloat32(data.position.y)
buffer.writeField(table.unpack(data.bossesKilled))
-- To do the math: 11 bytes for name (length prefix + raw bytes), 2 each for health, maxHealth, and points,
-- 8 for position, and an extra 1 for bossesKilled (though you could write 5 more bools without loosing any space!).
-- 11+6+8+1 = 26
local output = buffer.dumpString()
local bv = Instance.new("ModuleScript")
bv.Parent = game.ServerStorage
bv.Name = "Compiled?"
bv.Source = output
I’m running this code from the command bar. When I print:
print(output)
It does show me the compiled output string:
But the module script just remains empty.
Does anyone know why this is? I’ve seen multiple people work with BitBuffer so I don’t really understand why this doesn’t function correctly for me.
Thanks for the reply!