Auto-fill Username Script Help

  1. Don’t use StarterGui, use PlayerGui.
  2. PlaceholderText won’t work since it has a text already.

This post is 3 months old, I already explained why the script I posted didn’t work in the edit and replys.

didn’t even notice that fact, probably shouldn’t have replied then

So is this right?

local PlayerNameBox = game.PlayeGui.OrderingStart.EnterUserFrame.EnterUserTextBox
local AutoFillHelper = game.PlayerGui.OrderingStart.EnterUserFrame.AutoFillNameHelper

PlayerNameBox:GetPropertyChangedSignal("Text"):Connect(function()
	local PartialName = PlayerNameBox.Text
	local foundPlayer
	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.AutoFillHelper = CurrentPlayer.Name
			break
		end
	end
end)

no you don’t get PlayerGui from the game
you get it from the player

oh ok thanks for your help!!! i will tell you if it works

You get the PlayerGui from the player not the game, also changed your code so it can be more organized.

local Players = game:GetService('Players')
local player = Players.LocalPlayer

local playerGui = player.PlayerGui
local frame = playerGui.OrderingStart.EnterUserFrame

local PlayerNameBox = frame.EnterUserTextBox
local AutoFillHelper = frame.AutoFillNameHelper

PlayerNameBox:GetPropertyChangedSignal("Text"):Connect(function()
	local PartialName = PlayerNameBox.Text

	for i, CurrentPlayer in ipairs(Players:GetPlayers()) do
		if string.lower(CurrentPlayer.Name):sub(1, #PartialName) == string.lower(PartialName) then
			AutoFillHelper.Text = CurrentPlayer.Name
			break
		end
	end
end)

sorry to disturb, but i get this error

ServerScriptService.OrderingAutoFillText:4: attempt to index nil with ‘PlayerGui’ - Server - OrderingAutoFillText:4

Use a LocalScript instead of a Serverscript.

1 Like

alright it works!! thanks have a great day