I am trying to make a medkit and I have to use a remote event to give the player 100 health, so I'm in the server script service scripts and in one of the scripts, I'm trying to find the person who fired to the server and used the medkit by typing in: local Wielder = script.Parent.Parent.Workspace.Medkit.Parent.Parent:FindFirstChildWhichIsA("Humanoid") I tried it in different ways and I can't figure out how to find the player who fired to server.
Finding the character who is holding an item that fires to the server?
1 answer
The simplest way to accomplish this is to use the built-in arguments for the RemoteEvent. When a player fires a server event, it can carry across any arguments that you want.
local remoteEvent = game.ReplicatedStorage.RemoteEvent
remoteEvent:FireServer(argument1, argument2)
On the server side, there is an extra argument that is reserved for the player who fired to the server. When attaching this to a function, the first argument is the player.
local remoteEvent = game.ReplicatedStorage.RemoteEvent
function medkit(player, argument1, argument2) -- The server recieves a player argument!
-- Function code here
end
remoteEvent.OnServerEvent:connect(medkit)
So, to get the player's character in the workspace, all you have to reference from here when coding the function is player.Character.
For more information about RemoteEvents and RemoteFunctions, I recommend you check out this page on the developer documentation. It will provide more in-depth information on how these arguments can be applied.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please put your WHOLE code in the description. And, put it in code blocks, I'm getting really tired of telling people to have to put code in blocks, or having to tell people this isn't a request site. Sometimes I really wish people would read guide lines before asking something. So anyways, please put your whole code.