Server > Client Issues

so i have issue. i want to send player through FireClient but it not working. when the client gets it and i print i get “nil” here is my code
client

faceremote.OnClientEvent:Connect(function(Player)

server

faceremote:FireClient(Player)

how player define in server script

knife.OnServerEvent:Connect(function(Player, hit)

Roblox doesn’t pass any Player argument by default for OnClientEvent listeners because it is unnecessary.

However Roblox does this here because you will need to know which player fired the remote. Don’t worry about implementation details; just know Roblox knows what network it came from.

what but how do i get the player that did the server fire then… im try and make it where when keycode it make you character face towards your mouse… but this not work when i cant get player who fired it

Clients don’t fire the OnClientEvent, only the server does. Clients fire the OnServerEvent, however.

but you not answer my question; if i cant get the player who used skill from an arguement how will i get the player who used skill?

You are being unclear. Are you talking about OnServerEvent or OnClientEvent?

OnClientEvent because the local script do not know who used the skill, if i pass player through arguement then i will know who did skill in local script; but you tell me no so i dont know how else to do getting player from local script…

It’s hard to tell what you’re even asking. Can you edit your post to make more sense please.

okay i will try… sorry i’m not good english

You would use the LocalPlayer property of Players to determine the local player.

local Players = game:GetService("Players")

local client = Players.LocalPlayer

You don’t need the server to pass the argument for you; that is redundant. You already know who the local player is; Players.LocalPlayer.

but wouldnt that cause issue with the local player not being the player who fired the client event

Alright my understanding is that you don’t have a full understanding of what is passed when a remote is fired from the server to the client. The server passes the arguments after the first in :FireClient(). For example, if I do :FireClient(game.Players.ekuzodiaa, "TestString"), your client listener will be passed "TestString" and only that.

so i should do this?

:FireClient(nil,Player)

No. This is how you fire a RemoteEvent to a specific client:

Remote:FireClient(playerObject, ...)

Again; the server fires OnClientEvent, not the client.


so my only mistake was not putting dots? wow… such bad mistake

To expand on what @sjr04 said, The server does :FireClient() to send information to the client and client listens with .OnClientEvent. The client does :FireServer() to send information to the server and the server listens with .OnServerEvent

that did not help me because i already know that; just wording… also i never say the server fire onclientevent

Indeed you didn’t, which is why I am telling you that it does.

@oreoollie told you about default arguments

uhm it still not work… now the ... are red underlined, did you mean more arguements? but i dont need more arguements i just need to pass the player