As many are aware, roblox’s Value objects have a wonderful event that goes buy :Changed
For my purposes, making a lot of these would be counter intuitive, and it works better to use a module script instead.
The question is, how could I achieve similar functionality?
I was thinking of possibly creating a different module to manage it, something that might look like:
local Module = {}
function Module.Changed(ValueToListen)
local Initial = ValueToListen
while wait() do
if ValueToListen ~= Initial then
Initial = ValueToListen
return ValueToListen
end
end
end
However, I don’t think something like this would work, and if I ended up using it 50 million times I think it would significantly bog down performance.
Do you not want to use Changed because you only want to listen to one property change as opposed to listen to any property change? If so you can use GetPropertyChangedSignal(), with the parameter being the property it should wait to be changed.
game.Workspace.Part:GetPropertyChangedSignal("Color"):Connect(function()
print( "The part's color changed!" )
end)
This is an example, it runs whenever part’s color changes.
Besides for the part about it listening for any property to be changed I don’t understand why you wouldn’t want to use it.