Why is this bug occuring with FireAllClients?

Hello. Currently, I am making a Health System, and on the Server, I have a CharacterAdded event like so:
image

The problem is that when I pass the “Character” argument when firing the “Health” remote event, I get an error like so:

Here is my code on the Client that handles the OnClientEvent:

This seems so weird to me, because “Character” shouldn’t be a nil value, it should be a model. And I even printed the argument passed to the “Character” parameter on the server and it prints “Shinjaa”, not “nil”, on the client, it’s the opposite.

That error usually occurs when the character has not loaded. Because you are immediately firing the event when the character enters the server, the client may not have loaded the character model yet, and thus it is nil. I suggest sending the player data to the client and then let the client access the character.

2 Likes

Try firing to clients with :FireAllClients() instead of FireAllClients(character)
And on the OnClientEvent do

Boilerplate.Remotes.Health.OnClientEvent:Connect(function(player)
local Humanoid = player.Character:WaitForChild(“Humanoid”)
local Head = player.Character:WaitForChild(“Head”)

I’m not sure what the issue is here but it may be due to the Roblox character model being Archivable = false (Unsure here).

Try just sending the humanoid and the head and then deal with it there.