Finding a player name by using the shortened player name

I was thinking about making a command, that a billboard gui will show up above your head by saying kos then the player’s name. But instead of the exact player’s name, it’s become shortened. For example,

My command is “kos tcxtic_al”, instead of that, I will do “kos tcx” it becomes shortened.

Script:

local kos = game.ReplicatedStorage.KoS:Clone()

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(c)
		kos.Parent = c.Head
		
		p.Chatted:Connect(function(m)
			
			if m == "kos ".. p.name then
				kos.ImageLabel.Visible = true
			elseif m == "revoke kos " ..p.Name then
				kos.ImageLabel.Visible = false
			end
		end)
	end)
end)
1 Like
local name = string.sub(p.name, 1, 3)

This will truncate the username down to the first 3 characters.

1 Like

You can use string.match and manipulate it however you want.

2 Likes

But what about like, stating a player’s name 3 or more, so that I don’t have to repeat doing string.sub