How to make a character nickname?

Hi guys, I am trying to figure out how to make it so that when players enter a nickname for there characters it goes to the next screen. I have some of the nickname script already. It’s just I need help trying to get the user input so my nickname script can have something to hold.

I don’t know if I am on the right track of using user input here and the nickname script. or if there is a simpler way to get the text entered by the user.

Nickname script:

local HoldName = game:GetService("ServerStorage"):WaitForChild("holdname")
local Name = script.Parent.Parent.ReplicatedFirst.LocalScript.StartScreen.ChoiceFrame.NameLabel.Nametext
game.Players.PlayerAdded:Connect(function(player)
	local characterName = Instance.new("StringValue", player)
end)


game.ReplicatedStorage.CharacterName.OnServerEvent:Connect(function(player, name)
	print(name)
	if game:GetService('TextService'):FilterStringAsync(name,player.userId,Enum.TextFilterContext.PublicChat):GetNonChatStringForBroadcastAsync()== name then
	characterName = name
	print(characterName)
	local head = player.Character.Head
	
	local clonedtag = head:FindFirstChild("holdname") or HoldName:Clone()
	clonedtag.Name = characterName
	clonedtag.Parent = head
	else
		error('That name is NOT allowed!')
		end
end)

Choicescript(local script):

local userInput = game:GetService("UserInputService")

local create = script.Parent.Parent.Frame
local Name = script.Parent.NameLabel.Nametext
local Namelabel = script.Parent.NameLabel
local Textlabel = script.Parent.NameLabel.TextLabel
local text = "What is your name?"

local FirstFinished = script.Parent.Parent.Frame.LocalScript.FirstScreenFinished


FirstFinished.Event:Wait()

for i = 1, #text do
	script.Parent.NameLabel.Text = string.sub(text,1,i)
	local cor = coroutine.wrap(function()
	local sound  = Instance.new("Sound")
	sound.Volume = .5	
	sound.SoundId =	"rbxassetid://3682239219"
	sound.Parent = script.Parent.Parent
	sound:Play()
	sound.Ended:wait()
	sound:Destroy()
	end)
	cor()
	wait()
end

userInput.TextBoxFocused = Name
userInput:GetLastInputType()



	
script.SecondScreenFinished:Fire()

oh and just so you know the second screen is supposed to fire this screen(local script):

local text = "What moves you forward?"
local Courage = script.Parent.Parent.Courage

local SecondFinished = script.Parent.Parent.Parent.ChoiceScript.SecondScreenFinished


SecondFinished.Event:Wait()


for i = 1, #text do
	script.Parent.Parent.ChoiceLabel.Text = string.sub(text,1,i)
	local cor = coroutine.wrap(function()
	local sound  = Instance.new("Sound")
	sound.Volume = .5	
	sound.SoundId =	"rbxassetid://3682239219"
	sound.Parent = script.Parent.Parent
	sound:Play()
	sound.Ended:wait()
	sound:Destroy()
	end)
	cor()
	wait()
end

	for i = 1, 0, -.09 do
		Courage.TextTransparency = i
		wait(.2)
		
	end

Nice effort so far!

You could use a textbox for user input. TextBox | Documentation - Roblox Creator Hub

(I suggest you manually make the ui using the ui editor, then give the player that)

Well I want people to enter the name they want into the text box not a specific gui. Also How would I make it so that users input the text then press enter and it goes to the next screen?

TextBox.FocusLost:Connect(function(EnterPressed)
if not EnterPressed then return end -- checks if they didn't press enter then closes the function
local text = TextBox.Text
-- other stuff you need
end)
1 Like

wow that was easier then I thought it would be. Thanks it worked.

1 Like

Oh sorry, I just realized I forgot a line. Let me edit it.

1 Like

I added a line, if not EnterPressed then return end

1 Like