I am currently working on a check in system for a hotel group I am apart of. The system is set to help you auto fill player names, when you type in the name. The auto fill is what is breaking.
I do have it set to be correct, if the auto fill happens to malfunction, and the typed name is correct, however, it doesn’t seem to work.
targetPlayer
is the TextBox the user types the name into
errorMessage
is self explanitory
fillPlayer
is the auto fill text
plrTable
is the folder in RepStorage that has a list of all the players in game
Here is the script
local suite = script.Parent:WaitForChild("Suite room")
local targetPlayer = script.Parent:WaitForChild("TargetPlayer")
local errorMessage = script.Parent:WaitForChild("Bottom text"):WaitForChild("TextLabel")
local checkInFunction = game.ReplicatedStorage:WaitForChild("staffFunction")
local fillPlayer = script.Parent:WaitForChild("FillPlayer")
local plrTable = game.ReplicatedStorage:WaitForChild("plrs")
targetPlayer.Changed:Connect(function()
if targetPlayer.Text ~= "Username" and targetPlayer.Text ~= "" then
for i,v in ipairs(plrTable:GetChildren()) do
if string.match(v.Name,targetPlayer.Text) or string.match(fillPlayer.Text,targetPlayer.Text) then
targetPlayer.TextColor3 = Color3.fromRGB(255,255,255)
fillPlayer.Text = v.Name
elseif not string.match(v.Name,targetPlayer.Text) and not string.match(fillPlayer.Text,targetPlayer.Text) then
fillPlayer.Text = ""
targetPlayer.TextColor3 = Color3.fromRGB(255,0,0)
errorMessage.Text = "Invalid Username"
wait(1)
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
end
end
if targetPlayer.Text == fillPlayer.Text or plrTable:FindFirstChild(targetPlayer.Text) then
targetPlayer.TextColor3 = Color3.fromRGB(255,255,255)
end
end
end)
targetPlayer.FocusLost:Connect(function()
if not plrTable:FindFirstChild(targetPlayer.Text) then
fillPlayer.Text = ""
targetPlayer.TextColor3 = Color3.fromRGB(255,0,0)
errorMessage.Text = "Invalid Username"
wait(1)
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
else
targetPlayer.TextColor3 = Color3.fromRGB(255,255,255)
end
if targetPlayer.Text == "Username" then
targetPlayer.TextColor3 = Color3.fromRGB(255,255,255)
end
end)
standard.MouseButton1Click:Connect(function()
if targetPlayer.TextColor3 == Color3.fromRGB(255,0,0) then
errorMessage.Text = "Please fill in a correct username"
wait(3)
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
else
local checkIn = checkInFunction:InvokeServer(targetPlayer.Text,"standard")
errorMessage.Text = checkIn
wait(3)
targetPlayer.Text = "Username"
fillPlayer.Text = ""
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
end
end)
suite.MouseButton1Click:Connect(function()
if targetPlayer.TextColor3 == Color3.fromRGB(255,0,0) then
errorMessage.Text = "Please fill in a correct username"
wait(3)
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
else
local checkIn = checkInFunction:InvokeServer(targetPlayer.Text,"suite")
errorMessage.Text = checkIn
wait(3)
targetPlayer.Text = "Username"
fillPlayer.Text = ""
errorMessage.Text = "Version: 1.0, Scripted and Created by rooboo14 and Grufftomcat"
end
end)```
I appreciate all of the help!