A StringValue is an object whose purpose is to store a single Lua string. The length of the string can't be more than 200,000 characters (this will cause a "String too long" error). Like all "-Value" objects, this single value is stored in the Value property. The Changed event for this (and other objects like it) will fire with the new value being stored in the object, instead of a string representing the property being changed.
If the string is too long to be displayed in the Value field within Properties window, it will partially show the string contents followed by an ellipsis (...).
1-- Demonstrate the Changed event by creating a Part2local part = Instance.new("Part")3part.Changed:Connect(print)4-- This fires Changed with "Transparency"5part.Transparency = 0.56-- Similarly, this fires Changed with "Number"7part.Name = "SomePart"8-- Since changing BrickColor will also change other9-- properties at the same time, this line fires Changed10-- with "BrickColor", "Color3" and "Color3uint16".11part.BrickColor = BrickColor.Red()1213-- A NumberValue holds a double-precision floating-point number14local vNumber = Instance.new("NumberValue")15vNumber.Changed:Connect(print)16-- This fires Changed with 123.456 (not "Value")17vNumber.Value = 123.45618-- This does not fire Changed19vNumber.Name = "SomeNumber"2021-- A StringValue stores one string22local vString = Instance.new("StringValue")23vString.Changed:Connect(print)24-- This fires Changed with "Hello" (not "Value")25vString.Value = "Hello"
This event, like other changed events, can be used to track when an StringValue changes and to track the different values that it may change to.
For instance, this may be useful in games that rely on StringValues to track values such as NPC or item names.
1local value = Instance.new("StringValue")2value.Parent = workspace34value.Changed:Connect(function(NewValue)5 print(NewValue)6end)78value.Value = "Hello world!"