Is there a way to detect Value.Changed in a script before it happens like "Changing"

I want to make a failsafe script for a Leaderstats value and other scripts will be using it as the users rank

could i make it so if other scripts would use Statvalue.Changed they would only get the filtered Value by the watch script?

The script checks the value and if it’s not a valid rank it resets it so i wouldn’t error any script by having someones rank be some random string if it somehow glitches when a script changes it

so could i have a script look at it first and only then allow it like a “Changing” event like playerleaving so other scripts don’t get bad data?

what script gets the .changed event first??

script.Parent.Changed:Connect(function()
	local prp = script.Parent.Value
	if table.find(_G.r,prp) then else script.Parent.Value = "Player" end
end)
2 Likes

I don’t really think it will be possible for the value to glitch out, unless the way you are changing it is really weird.

I personally don’t think you need to worry about the data glitching, however if you still insist on adding stuff, the way you could do it is have every Value.Changed thing have a task.wait() yield (really short delay), and have another script which detects the change and processes it, without having any yield.

i just also thought i could make two values I guess but I wondered if there is a built in way

To the best of my knowledge, there is not a built in way to process a value prior to the .Changed event.

Your proposed solution, with two values, would require a third value as well, as you have no way to know which of the 2 values is correct otherwise!

I still stand by my initial point that you probably don’t need to be trying to check for corrupted data.

You should anticipate the thread where it actually starts changing the value and not using the Changed event(which anticipates it after the change).