Attempt to index nil with char

I’m trying to make it when the remote event fire it put a gui over the other player head.

Module script:

local index = math.random(#candidates)
		local player1 = candidates[index]
		local RS = game:GetService("ReplicatedStorage")
		local ClientGui = RS.Events:WaitForChild("ClientGui")
		QuestName.Value = Name
		QuestDescription.Value = "Kill " .. player1.Name .. " in this amount of time."
		local char = player1.Character
		if char then
			local Tracker ="BoolValue", char)
			Tracker.Name = "Tracker"
			ClientGui:FireClient(Player, char)
				if (Player.Character.HumanoidRootPart.Position - char.HumanoidRootPart.Position).magnitude < 55 and Tracker then
					Module.Reward(Player, Folder, 5)
					if char:FindFirstChild("Tracker") then

Local Script(Remote Event)

local RS = game:GetService("ReplicatedStorage")
local ClientGui = RS.Events:WaitForChild("ClientGui")

ClientGui.OnClientEvent:Connect(function(Player, enemychar)
	print("Remote Event fired")
	local BillBoardGui = script.BillboardGui:Clone()
	BillBoardGui.Parent = enemychar:FindFirstChild("Head")
	BillBoardGui.StudsOffset =, 5, 0)

Anyone know why it not working?

The issue lies here.

When the client receives a .OnClientEvent event, it doesn’t pass the “Player” argument, since it’s the client itself. It has full access to the player receiving the request.

So your enemy is actually the “Player” variable, and since there’s no secondary arguments, the “enemychar” is considered nil.


Is there anyway to bypasws this issue to send the character to the client?

I don’t think you understood my response, let me try to make it more clear for you.

In this line, you’re firing a ClientEvent to client “Player” and passing the argument “char”.

When you receive the event, the client script doesn’t read the “Player” argument, as you wouldn’t need to know the player since you’re the client, therefore you can only control a single player, which is the one receiving the signal.

If you fix the line to

It’ll work perfectly.

1 Like

I get it now. Thanks for the help!