NameTag not working

So, I am trying to script some nametags.

local function cvChecker(character, ntClone)
	if character:GetRankInGroup(13016143) > 0 then
		print("rifles")
		ntClone = riflesTag:Clone()
		wait(.1)
		ntClone.Parent = character:FindFirstChild("Head")
		ntClone.Adornee = character:FindFirstChild("Head")
		ntClone.playerName.Text = character.Name
		ntClone.playerRank.Text = "<font color='#FF7276'> [Civillian], </font> "..playerRank 
		ntClone.Enabled = true
	end	
end

rfChecker.OnServerEvent:Connect(rfChecker)	

edit: *** this is a server script inside of startercharacterscripts. thats probably the issue but i do not know how to solve it ***

The problem is that it doesn’t work for some reason. The BillBoard GUI does not move to the players head.

What I don’t understand is why it works when it’s not inside the function/ not activated by the Remote Event.

Anyone know why or what I’m doing wrong?

is the character argument a player

dont think so. pretty sure its not

Try changing:

local function cvChecker(character, ntClone)
	if character:GetRankInGroup(13016143) > 0 then
		print("rifles")
		ntClone = riflesTag:Clone()
		wait(.1)
		ntClone.Parent = character:FindFirstChild("Head")
		ntClone.Adornee = character:FindFirstChild("Head")
		ntClone.playerName.Text = character.Name
		ntClone.playerRank.Text = "<font color='#FF7276'> [Civillian], </font> "..playerRank 
		ntClone.Enabled = true
	end	
end

Into:

local function cvChecker(player, character, ntClone)
	if player:GetRankInGroup(13016143) > 0 then
		print("rifles")
		ntClone = riflesTag:Clone()
		wait(.1)
		ntClone.Parent = character:FindFirstChild("Head")
		ntClone.Adornee = character:FindFirstChild("Head")
		ntClone.playerName.Text = character.Name
		ntClone.playerRank.Text = "<font color='#FF7276'> [Civillian], </font> "..playerRank 
		ntClone.Enabled = true
	end	
end

Also, the first argument of OnServerEvent is always the player. From there on the rest of the arguments are the ones you actually passed through the function.

You can see it Here:

1 Like

Instead of putting the Adornee to the player put the entire parent to the player

1 Like

This then creates the error, " attempt to index nil with ‘FindFirstChild’ " on the line where it says:

ntClone.Parent = character:FindFirstChild("Head")

Can you show me the code which includes the :FireServer() function with its arguments?

And the way you’re getting the character from the client.

FireServer():

rifles.MouseButton1Click:Connect(function()
	rifChecker:FireServer()
	print("re fired")
end)

And for the way I’m getting the character from the client, I’m not really sure. I’m new to scripting and I kinda just put character there. That’s probably part of the issue. All I know is that character is defined like this:

local character = script.Parent

-earlier on in the script but I don’t think that affects what’s in function.

*I dont think anything is sent from the client.

Well basically you’re not passing the character through the function right here:

rifles.MouseButton1Click:Connect(function()
	rifChecker:FireServer(-- character instance is missing here. --)
	print("re fired")
end)
1 Like

So you’re saying you’re using :FireServer() on the server?
(On a Server script not a localscript)

No, it is sent from a localscript.

Alright, try using this function here:

local function cvChecker(player, character, ntClone)
	character = character or player.Character or player.CharacterAdded:Wait() -- // Making sure the character really exists.
	if player:GetRankInGroup(13016143) > 0 then
		print("rifles")
		ntClone = riflesTag:Clone()
		wait(.1)
		ntClone.Parent = character:FindFirstChild("Head")
		ntClone.Adornee = character:FindFirstChild("Head")
		ntClone.playerName.Text = character.Name
		ntClone.playerRank.Text = "<font color='#FF7276'> [Civillian], </font> "..playerRank 
		ntClone.Enabled = true
	end	
end
1 Like

yea looks like that was the issue. thanks

1 Like