I am doing this as kind of a test for a matchmaking system. I have no clue why its not working all the way. I need it to update every time something new is added to the textbox. it only prints right as i join the game. Any idea?
local TextBox = script.Parent.Type
local Text = TextBox.Text
local Letters = string.len(Text)
print(Letters)
You need to have an event trigger in your code for when the Text property is changed.
local TextBox = script.Parent.Type
TextBox:GetPropertyChangedSignal("Text"):Connect(function() --This looks for when the text property has changed
local Text = TextBox.Text
local Letters = string.len(Text)
print(Letters)
end)
so sorry for wasting your time, when you gave me the example code, I just typed it up (because i like my scripts a certain way) and made it GetPropertyChangedSignal("text") instead of GetPropertyChangedSignal("Text"). so yes, i was actually getting an error
so its just multiplying the number I had when I joined, every time i hit a new letter it just multiplies it by 1 (which of course doesnt change the actual number) it even does it when i hit back space
I want it to print another print every time i add a letter/number
The first issue with the multiplication I’m not sure what would be causing that. I’ll work on a solution for the second issue.
EDIT: Below script will only print when a non-space character is added and will only print out the number of non-space characters. This is handled by using string.gsub to replace spaces with empty strings.
local TextBox = script.Parent
local lastStringNoSpaces = ""
TextBox:GetPropertyChangedSignal("Text"):Connect(function() --This looks for when the text property has changed
local Text = string.gsub(TextBox.Text," ","")
local Letters = string.len(Text)
if Text ~= lastStringNoSpaces then
print(Letters)
lastStringNoSpaces = Text
end
end)