Can't find player

Hello, I’m getting some problems when I try to get the player from a server script after firing an event.

local event = game.ReplicatedStorage:WaitForChild("Push")
local plr = game.Players.LocalPlayer

event.OnServerEvent:Connect(function(input, V1)
	local char = plr.Character
	local hum = char:WaitForChild("Humanoid")
	if hum then
		print("Hum")
	end
end)

This is what I have done so far, it’s not alot but it’s just a test so I know how to get the player after using parameters on the function. As you can see, after I fire the event I’ve got 2 parameters: “Input”, which is the name of the function and “V1”, which is the variable I want to keep from the local script.

It all works correctly but when I try to get the character this is the error that shows up: ServerScriptService.Push:5: attempt to index nil with ‘Character’

I have trying making the player part of the parameters and it does work but then it breaks the other variables.

In case I haven’t been clear I’ll try to answer your questions.
Thank you!

You missing the Player parameter

event.OnServerEvent:Connect(function(Player,input, V1)

.LocalPlayer doesn’t work on a ServerScript. You should have plr passed as a parameter on the event.

1 Like

You are right. I kept writing the parameter after the function’s name so It would count the player as a part of it. It does work when I put it first. Thanks!

You are right, I found out that the player goes before the function. Thanks!