Remote Event not working as what I expected

Hello!, I am Currently trying to achieve sending information from a local script to a server script, Both of those script are inside a tool including the remote event

Now for the issue, the issue is that the server recognize that both of the information from client is a player, now this made me very confused, here are the scripts

Client (The part that is important)

	tool.Activated:Connect(function()
		local target = mouse.Target
		sender:FireServer(player, target)
	end)

And now the Server Script (With debugs I tried)

sender.OnServerEvent:Connect(function(player, block)
	print(player)
	
	print(block)
end)

Now after that, I tried to run the game and here are the outputs from the debug of that server script (Sorry for bad quality)

ggt

Im not so sure of what I missed on here, can anyone help?

Your script is perfectly fine, first it printed your player name, and second, your mouse target was your own character, thus it printed the same!

The Mouse’s Target Apparently Is the player’s Character Itself.
Did you Check that?

No, i was not aiming at my own character, i was aiming at a block

Have you tried in first person, or when zoomed out so you can be sure roblox detected it correctly?

Firing a RemoteEvent or RemoteFunction automatically passes in the player object that fired it.

You do not need to pass in the player name when firing the event. In this case, it should be the following:

sender:FireServer(target)

The server side of things is fine. If the server cannot see the object that you’re sending it and instead shows as “nil”, make sure the part is created on the server and not the client.

Edit: The player firing the event is always the FIRST argument to a RemoteEvent or RemoteFunction listener.

3 Likes

I’ll try that, i think that might work