Can you block/trace/stop a scripts actions

So I have sorta a question sorta confused and sorta I’m seeing if this is possible. But lets say you have a script somewhere. And that script changes a parts parent from Workspace to ReplicatedStorage. Would there be a way to prevent that from happening. Like for example could you restrict that action/block it? Or could you find a way to trace it back to what scripted did that action in order to delete it. (For example some backdoor script) Some of the things I explored were stuff like using this below. Just wondering if there was anything or if anyone has some tips for me on things I can/should do.

local part = game.Workspace:FindFirstChild("Part")
part.AncestryChanged:Connect(function(s, parent)
	if parent ~= game.Workspace then  
        part.Parent = game.Workspace
		print("bad part. You stay in workspace")
	end
end)

AFAIK there is no way to do this. No property change events pass any more arguments than parents or property names.

The only way to stack trace is in ScriptContext.Error and that’s limited to errors only. I suppose you could destroy the instance and listen for another script to parent it, causing an error, but this would probably lead to tons of false positives.

You could probably also do this with modules as you’d be able to access the “variables”/references to the instance but the virus scripts would have to be made to specifically work with your module but really, that won’t work as viruses are meant to work against your game, not for your game.

1 Like