RemoteEvent Returning Nil

Hello @Water_KKnight here.

I’m trying to send a remote event from a module script to a client via a heartbeat connection (region3) on the server. There is a debounce for the dmg and event.

if EHum then
	if not object:IsDescendantOf(Character) then
		if not EHum:FindFirstChild(player.Name.." Bomb") then 

			local debounce = Instance.new("BoolValue",EHum)
			debounce.Name = player.Name.." Bomb"
			Debris:AddItem(debounce,4)

			coroutine.wrap(function()
				ERP.Anchored = true
				wait(5)
				ERP.Anchored = false
			end)()

			EHum:TakeDamage(10)
			BombCam:FireClient(player,EHum)
			warn(EHum.Parent)
		end
	end

end

The module is working as intended except:
I’m firing the enemy humanoid’s parent.Name to the client. However, the client is receiving nil, whereas printing it on the server seems perfectly fine.

Screen Shot 2021-05-22 at 12.17.14 PM

I’m not sure where the problem’s origin is, and I would appreciate any help :slight_smile: . Thanks.

The only issue it could be is if the client cannot see the dummy that the server sees because it is server sided, maybe that could be your issue since it works fine for the server but not for the client?

What exactly is EHum belong to?

A Dummy’s humanoid detected in a region3

 for _, object in pairs(partsInRegion) do
      if (object.Parent:FindFirstChild("Humanoid")) then
           -- code executed

I think I see your issue as to what you wanted to do

You’re passing in EHum, not the name of the parent of the ehum, I think

BombCam:FireClient(player,EHum)

Should be

BombCam:FireClient(player,EHum.Parent.Name)

To achieve what you wanted

I should be able to get EHum.Parent.Name on the client (as well as other properties of EHum) since it’s passing through EHum on the server.

BombCam:FireClient(player,EHum.Parent.Name)

still returns nil.

That’s odd, maybe something is wrong with the OnClientEvent, may I see the full code related to it, including the parameters?

BombCam.OnClientEvent:Connect(function(player,EHum)
     warn(EHum)
end)

client script

Get rid of player, it’s the cause of the nil, you don’t put it as the first parameter for OnClientEvent, only for OnServerEvent

BombCam.OnClientEvent:Connect(function(EHum)
     warn(EHum)
end)

You still need to pass the player in FireClient as the server doesn’t know who to fire it to

1 Like