I'm creating a GUI system that creates a Team with a desired name that the player inputs into a TextLabel on the GUI. I have it all working correctly except for a part where the script is supposed to check if the TextLabel's Text was changed and, if so, it should print what was changed. The problem is that "AbsolutePosition" is printed so many times after the GUI Frame moves into it's Position, when :TweenPosition()
was used. Below is the script.
local teamName = "" local CreateTeamGui = script.Parent local CreateTeamActivated = false function nameInput(name) if CreateTeamActivated == true then for i = 1, #name do teamName = string.sub(name, 1, i) end print(teamName) --This is what's printed when TeamNameLabel.Changed is called end end script.Parent.Parent.GuiHandler.ForCreateTeam.OnServerEvent:connect(function() --Event is called when the player clicks on a button to Create a Team then checks for the following: if script.Parent.Parent.CreateTeamActive == false then return else CreateTeamActivated = true end end) CreateTeamGui.TeamNameLabel.Changed:connect(nameInput) --I tried other things and of course doing TeamNameLabel.Text.Changed is not a thing... :C
I believe that something on wiki's string manipulation page should help with this partly but I have no idea what. If anything else you guys think should be changed then please add that to your answer. So Appreciated, Much Thanks.
local teamName = "" local CreateTeamGui = script.Parent local CreateTeamActivated = false CreateTeamGui.TeamNameLabel:connect(function() if CreateTeamActivated == true then for i = 1, #name do teamName = string.sub(name, 1, i) end print(teamName) --This is what's printed when TeamNameLabel.Changed is called end end) script.Parent.Parent.GuiHandler.ForCreateTeam.OnServerEvent:connect(function() --Event is called when the player clicks on a button to Create a Team then checks for the following: if script.Parent.Parent.CreateTeamActive == false then return else CreateTeamActivated = true end end)
Yeah, this might work. Sometimes it is better to do the function first :)
Changed gives both the property that changed, and it's new value
Try changing your function to this
function nameInput(property) if CreateTeamActivated == true then if property == 'Text' then print(textThingy.Text) -- what the Text was changed to. Change textThingy to suit your code. end end end
I apologise in advance for the tabbing. There doesn't appear to be a tab button on the iOS keyboard.