Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Detecting The Original Values of Objects?

So basically I am making well... The next generation of LUA-Learning? Idk... Anyways I needs to figure out how to get the original value of any object because if the player typed in a script that goes like

script.Parent.Position = Vector3.new(0,0,0)

I would need to know what the original position of the object was to see if it moved, or if it changed brickcolors such as in

script.Parent.BrickColor = BrickColor.new("Maroon")

I would also need to know if that changed.

2 answers

✓ Accepted answer

If you want to see whether a part changed or not you need to make use of the changed function.

Ex:

script.Parent.Changed:Connect(function()
	print("position changed!")
end)

If I were to move the part in studio (even a small stud) it will print("position changed").

Now for the color:

script.Parent.Changed:Connect(function()
	print("position changed!")
	if script.Parent.BrickColor ~= BrickColor.new("Really blue") then
		print("COLOR WAS CHANGED!")
		else
	end
end)

If I (or a player) were to change the part's color, it'll print "COLOR WAS CHANGED!"

So basically, before the player does anything, you can "snapshot" the parts position. Same thing with the brickcolor.

local orgPos = script.Parent.Position

local orgColor = script.Parent.BrickColor

Should work, lemme know if you have any errors. Cheers, Zander!

2 comments

0

What if the script made by the player changed the color before those variables are set?

0

You define those variables first lol.

This discussion is preserved as it was. New answers, comments, and votes are closed.