Can a server connect to client to check client's health?

A quick question: can a server initiate a connection to a “remote event” handler on a client or some such? Assuming we have a list of connected players on the server, can either use that connection or establish a new connection to check of the client side’s script is “healthy” or not. If not, can a client expose an HttpService endpoint to the server?

Yes they can, via “RemoteEvent::FireClient” on the server and catching that response via “RemoteEvent.OnClientEvent” on the client.

If this isnt what you wanted then I’m sorry, I’ve had a trouble understanding your request.

1 Like

Yes, looks like it may work. I’ll read up on the API of FireClient a bit, but it looks like what I need. Thanks!

1 Like

A humanoid’s health is already managed by the server. This would only be necessary if you intend to change the humanoid’s health on the client.

Oh, I am not specifically looking for the humanoid’s health property, but an overall client side’s instance’s integrity I expect it to have.

If I understand correctly, considering you want two-way communication, i.e; server requests information from client, client returns said information to server. This could be achieved via a single RemoteEvent instance, take the following for example.

--SERVER
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated.Remote

Players.PlayerAdded:Connect(function(Player)
	Remote:FireClient(Player)
	print("Server firing the client!")
end)

Remote.OnServerEvent:Connect(function()
	print("Server fired by the client!")
end)
--CLIENT
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("Remote")

Remote.OnClientEvent:Connect(function()
	print("Client fired by the server!")
	Remote:FireServer()
	print("Client firing the server!")
end)

However, for this type of communication (2-way), a single RemoteFunction is the more favorable option, take the following for example.

--SERVER
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated.Remote

Players.PlayerAdded:Connect(function(Player)
	local Response = Remote:InvokeClient(Player)
	print("Server invoking the client!")
end)
--CLIENT
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("Remote")

Remote.OnClientInvoke = function()
	print("Client invoked by the server!")
	return true
end

In that second example “true” is returned by the invokee (the client) back to the invoker (the server). If the variable “Reponse” were to be printed, “true” would display in the console.

1 Like

That’s a quite a comprehensive answer, thanks! I will look into the differences between FireClient and InvokeClient.