I am making a support system, and I want my administrators to be able to write with leading (space between lines). So when they press enter, a line break is added, and it gets saved to a datastore. However when they load it in, I still want the line breaks to be there.
then you only use the characters in the new text that have been newly added, by keeping track of the old text and using string.sub
local oldText = TextBox.Text
TextBox:GetPropertyChangedSignal("Text"):Connect(function(newText)
local oldTextLength = #oldText
if oldTextLength < #newText then
local newlyAddedCharacters = string.sub(newText, oldTextLength)
end
oldText = newText
end)
with that, you check if a newline is anywhere in the newly added characters, and if so, you just ask the server to save all the text
if string.find(newlyAddedCharacters, "\n") ~= nil then
-- Ask server to save text
end