I’m currently developing an Ordering System for my cafe, and I’m working on the input username GUI. Basically, I want it so when the player types in the first few letters of a customer’s username it automatically appears as the placeholdertext if it finds a player and then if they keep typing, if it’s the incorrect username it’ll keep searching the players until it displays the correct username as the placeholdertext.
local text = (the location of my textbox here) -- use this for assistance with changing the placeholdertext
function getFullNameFromPartial(PartialName)
local foundPlayer = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local CurrentPlayer = Players[i]
if string.lower(CurrentPlayer.Name):sub(1, #PartialName) == string.lower(PartialName) then
foundPlayer = CurrentPlayer.Name
PlayerNameBox.PlaceholderText = CurrentPlayer.Name
break
end
end
return foundPlayer
end
Let me know if you can provide any help with this, thanks!
You could try creating a variable for checking your if statement & print that out, to see what it results as? Possibly something like this:
local text = (the location of my textbox here) -- use this for assistance with changing the placeholdertext
function getFullNameFromPartial(PartialName)
local foundPlayer = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local CurrentPlayer = Players[i]
local PlayerCheck = string.lower(CurrentPlayer.Name):sub(1, #PartialName)
print(PlayerCheck)
if PlayerCheck == string.lower(PartialName) then
foundPlayer = CurrentPlayer.Name
PlayerNameBox.PlaceholderText = CurrentPlayer.Name
break
end
end
return foundPlayer
end
I think it works, but the thing is I have it set to fire when the Continue button is clicked, so it’s a MouseButton1Click event. How would I make it function as the player is typing? Would I make a LocalScript under the TextBox? Also, the PlaceHolderText seems to disappear once the player starts typing. Do you know how to make it stay or will it reappear once the script fires?
PlayerNameBox:GetPropertyChangedSignal("Text"):Connect(function()
local foundPlayer = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local CurrentPlayer = Players[i]
if string.lower(CurrentPlayer.Name):sub(1, #PartialName) == string.lower(PartialName) then
foundPlayer = CurrentPlayer.Name
PlayerNameBox.PlaceholderText = CurrentPlayer.Name
break
end
end
return foundPlayer
end
end)
Every Object has a variety of properties, if you want to detect changes from a certain property you can use the GetPropertyChangedSignal Event, then find the property you want to detect when it changes
local Part = workspace.Part
Part:GetPropertyChangedSignal("Transparency"):Connect(function()
print("The part's transparency has changed!")
end)
wait(10)
Part.Transparency = 1
PlayerNameBox:GetPropertyChangedSignal("Text"):Connect(function()
local foundPlayer = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local CurrentPlayer = Players[i]
if string.lower(CurrentPlayer.Name):sub(1, #PartialName) == string.lower(PartialName) then
foundPlayer = CurrentPlayer.Name
PlayerNameBox.PlaceholderText = CurrentPlayer.Name
break
end
end
return foundPlayer
end)