Uses of Instance:IsPropertyModified()

So 580 just came out and I was wondering how could I actually use the new instance APIs.
Instance:IsPropertyModified() and Instance:ResetPropertyToDefault(), will they be used for anti-cheat purposes or not?

Wow, this is interesting!

The official #updates:release-notes #580 aren’t even here yet, and those are still pending updates. :IsPropertyModified() and ResetPropertyToDefault() are not enabled yet.

The GitHub reference doesn’t mention these two methods yet, but they can be found on the Dev Hub (Instance | Documentation - Roblox Creator Hub).

Since this is part of base instance class, it will work on any instance, e.g. print(ServerScriptService:IsPropertyModified("LoadStringEnabled")) --> false.

I guess one passes property name, and it gets restored to default.

I suppose they could, especially in local anti-cheats. Since the majority of properties don’t replicate from client to server and other clients, server won’t be able to utilize this for any properties that don’t get copied over the boundary.

Still, these are a pretty amazing feature, especially the one for restoring to default. I will definitely be using this!

5 Likes

I think this has to do with StyleSheets and UI.

Further checking more into this, I believe that it is.

To use the APIs to explore them, you need FFlagEnableModifiedPropertyLuaApis. This will enable the two Methods.

image

Then you can create a Frame and use

print(game.StarterGui.ScreenGui.Frame:IsPropertyModified("BackgroundColor3"))

It will print true if you used right click buttons to create it.

image

This is how the frame looks like.

If you use

game.StarterGui.ScreenGui.Frame:ResetPropertyToDefault("BackgroundColor3")

image

It will reset. Now it has the same BackgroundColor3 as when you’d create the Frame with Instance.new

 

This property modification, is probably defined by the Engine, I am not sure what it does to check. But I don’t believe it can be used for custom anti-cheat, as this is something entirely different.

I believe it sorta works like Metatables. If you overwrite a property, it adds it onto the own Object and not it’s meta. And I think that’s how it checks if you’ve modified the property or not. And resetting it, simply erases the value out of the Object, and now it will use the meta defined object.

Example of what I mean

Please note that this example metatable code, is to showcase what I mean Don’t create metatables that way.

If I’d have done name.name = {} every Constructed Object would not have its own table, it would use the table address from the metatable itself.

local name = {}
name.__index = name

name.name = "Hi" -- For demonstration, if you'd put {}, it would bring issues, put it inside the Constructor instead. You can set it to nil for autocompletion though.

function name.new()
	local self = {}
	
	return setmetatable(self, name)
end


local newName = name.new()

warn("Our table")
print(getmetatable(newName), newName.name)


newName.name = "Hello"
warn([[Now we added a property,
but the original meta defined property, is still the same]])
print(newName)
print(getmetatable(newName))


newName.name = nil
warn("If we erase it, we return back to name")
print(newName, newName.name)