Help with command for BillBoardGui

Hello, my name is Kyleskate226. I asked for help to be pushed in the right direction on a topic, and a Programmer gave me an entire script. But I can’t seem to get the script to work, it has no errors, and no one seems to know how to fix it.

Instructions on what I did:

  1. I made a billbooard GUI and put it in Server Scrpt Storage, then I added a frame, and I added a text Label. And renamed it Rank

  2. I added a script, and put the script in it.

Script:

``game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local message = string.sub(msg, 1, 9)
if message == “:Authorize” then return end
local player_name = string.sub(msg, 9, #msg)
local player = game.Players:FindFirstChild(player_name)
local char = player.Character or player.CharacterAdded:Wait()

	local clone = script.BillboardGui:Clone()
	clone.Parent = game.Workspace:WaitForChild(player.Name).Head
	clone.Frame.Rank.Text = "Authorized"
	wait(1) -- however many seconds you want to show "authorized" for.
	clone:Destroy() -- destroy the authorized
end)

end)```

Change the

string.sub(msg, 1, 9)

to

string.sub(msg, 1, 10)

The string “:Authorize” has a length of 10, not 9.

Ok, I will try it. Thank you. [CHAT MINIMUM]

Actually, what are you trying to do? When they say “:Authorize (player)” is it supposed to add the GUI?

Yes, it’s supposed to like name them Authorized. For like boarders.

I have to try it when I get home, and I will let you know.

In that case this should work:

local showTime = 1 --How long the Authorized tag shows for
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message) --Fires when the player chats
		local command = string.sub(message, 1, 10)
		if command == ":Authorize" then --If the first 10 letters of their chat message is "Authorize"
			local name = string.sub(message, 12, #message)
			local player = game.Players:FindFirstChild(name)

			if player and player.Character then--If the player exists
				local character = player.Character
				if character:FindFirstChild("Head") then
					local clone = script.BillboardGui:Clone()
					clone.Frame.Rank.Text = "Authorized"
					clone.Parent = character.Head
					
					wait(showTime) 
					
					clone:Destroy()
				end
			end
		end
	end)
end)

I am back, tested it, and it worked! Thank you!