FakeUpdatedObject Module - StringValues, BooleanValues, NumberValues, etc. in pure lua

FakeUpdatedObject is a new Module made by me for the sake of replacing Values

With methods based on Values:

GetPropertyChangedSignal(Property)
GetValue(Property)

You can get the module here:

FakeUpdatedObject.lua (2.6 KB)

Examples:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FakeUpdatedObject = require(ReplicatedStorage.FakeUpdatedObject)

local NewCFrameValue = FakeUpdatedObject.new()
NewCFrameValue:SetValue("CFrame", CFrame.new(0, 0, 0))

NewCFrameValue:GetPropertyChangedSignal("CFrame"):Connect(function()
	
	warn(NewCFrameValue:GetValue("CFrame"))
	
end)

NewCFrameValue:SetValue("CFrame", CFrame.new(1, 1, 1))

If you find any problems with this post or you can make the post better, Let me know!

Bug reports are appreciated.

2 Likes

Hi! Just wanted to ask you; what are the use cases of this Module? Is it for UI stuff? - though this is one of the things I can think of here.

Thanks, and also thanks for sharing this code out!
Happy coding!

It is used to replace ValueObjects like BooleanValue and more because using ValueObjects just add to the instance count which increases the memory usage and because you can store multiple values using this module. Those are a few of the benefits

I doubt this saves up on a lot of memory when you’ve replicated the use behaviour in a module script. Your module might actually take up more memory per object than using traditional value instances. Whilst also removing the ease of access of having ValueInstances in the game environment.

no way that a table with some functions will be more expensive than a whole instance

I think you overestimate how much data an instance takes up, especially ValueObjects. They have a lot of functions but they’re all inherited from the global Instance class anyway so adding more ValueObjects isn’t expensive. I understand instances like parts, scripts and remote events may be more expensive and they need that for their functionality. ValueObjects on the other hand have one function and that is to hold a single value.

As far as I know, this wouldn’t save alot of memory but Values still take more memory than this, and the usecase for this module is not to share the object, but to detect changes in the values for one script, it is also better to use one object with multiple values for a script.

Including the memory cost it would take to add a module and all its extended functions it wouldn’t start improving memory usage until you start using a lot of ValueObjects. Also if all these FakeValueObjects are in one script surely its just better to use a function to change a value instead of connecting to events all inside one script.

your use case

local value = FakeUpdatedModule.new()
value:Set('boolean', true)

value:GetPropertyChangedSignal('boolean'):Connect(function()
  print(value:GetValue('boolean'))
  -- do code
end)

surely its just better to

local thing = {}

function updateValue(index, value)
  thing[index] = value
  -- do code
end

updateValue('boolean', true)

One ModuleScript (consisting of a bunch of tables and functions) would not take much more than an Instance, even if it doesn’t do much, better safe than sorry.

It is also very unlikely to use a little amount of ValueObjects, and when you start using more of these, it becomes a problem. Which this module helps with.

All of this module combined uses less memory than a normal ValueObject, and to respond to the code you’ve given, because the module doesn’t take more than ValueObjects, there is no problem with using it and it has more accessibility and it is easy to use like a normal ValueObject.

50 of my module also takes less than ValueObjects, this is tested so i can confirm.

I have to go now, bye!

How did you test this, roblox sucks at showing instance memory cost for some reason.