Way to combine 2 texts into one?

So im trying to create a custom name thing, where theres a list of first and last names and you pick what you think fits best, but I dont know how to make this work, as in making those 2 names combind. Any help?

Are you asking how to combine strings? You can do so by using two periods between the phrases.

local string1="this is some text written by"
local string2="a robot"
local combinedString=string1.." "..string2
3 Likes

Just for reference, this (..) is called the concatenation operator.

3 Likes

I have this text so far, am I doing something wrong when finding the first name?

local before_name = true;
local ts = tostring
game.Players.PlayerAdded:connect(function(player)
repeat wait() until player.Character
	local char = player.Character
	getRole(player)
	player.Changed:connect(function()
		repeat wait() until player.Character
			wait()
			getRole(player)
	end)
end)
function createTitle(p, s)
	local gui = script.Title
	local clone = gui:Clone()
	clone.Parent = p.Character.Head
	if before_name then
		clone.F.T.Text = s.." "..p.leaderstats.FirstName
	else
		clone.F.T.Text = p.leaderstats.FirstName..", "..s
	end
end

function getRole(player)
	local ln = player.leaderstats.LastName.Value
	player.Character.Humanoid.NameOcclusion = "OccludeAll"
	if player.Character.Head:findFirstChild("Title") then
		return false
	elseif not player.Character.Head:findFirstChild("Title") and player:IsInGroup(ln) then
		local rankString = player:GetRoleInGroup(ln)
		createTitle(player, rankString)
	elseif not player:IsInGroup(ln) then
		createTitle(player, "Citizen")
	end
	
	
end

If FirstName is a StringValue object, you need to do FirstName.Value.

1 Like

Its still not giving me an error saying “Theres no first name in leaderstats” (Waiting for this to work to start that process)

If there’s nothing named “Title” in the character’s head it’ll never call the function to create a title. That might be the issue, I’m not sure. Are there any other errors?

1 Like

I want an error, the only error is the lastname, im not getting a firstname error.

What error is that? If your code errors once, it’ll stop running.

1 Like

Well by that logic, the firstname should error first, and its not.

1 Like

It should be giving the player the title, as in the

function createTitle(p, s)
	local gui = script.Title
	local clone = gui:Clone()
	clone.Parent = p.Character.Head

If the function returns false, it will never call createTitle.

1 Like

How come you using Player.Changed instead of Player.CharacterAdded?

2 Likes

Ahh yes! I did not understand you correctly when you said the code stops. No wonder. it was never letting it get to the first name, meaning it would never error it!

1 Like

Just for the future, I think it is proper etiquette to mark the person who helped you as the solution instead of your reply to it, considering they took the time to reply to several of your responses.