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)
Oh, yeah, my previous script that I had functioning when a button was clicked was this which defines it:
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
break
end
end
return foundPlayer
end