Attempt to index nil with 'Character'

server cant get player character (it exists!)
when player use tool, localscript fires server for get server player name
however, even thought server gets fire, player still unknown

CLIENT:

local tool = script.Parent
local remote = tool:WaitForChild("throwFunction")
local event = tool:WaitForChild("throwEvent")

local players = game:GetService("Players")
local uis = game:GetService("UserInputService")

local plr = players.LocalPlayer

local rig = script.Parent.rig

rig.Value = tostring(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").RigType)

remote.OnClientInvoke = function()
	return plr:GetMouse().Hit.p
end

script.Parent.Activated:Connect(function()
	game.ReplicatedStorage.possession.getplayer:FireServer()
	game.ReplicatedStorage.possession.CLIENT_:Fire()
end)

SERVER:

local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")

local player2 

local botname = replicatedStorage.possession.current_bot

local bte = replicatedStorage.possession.bot_possessed_b

replicatedStorage.possession.getplayer.OnServerEvent:Connect(function(Player)
	player2 = Player
	print(player2.Name) -- this prints my player name
end)

local physics = game:GetService("PhysicsService")
local possessmodule = require(replicatedStorage.possession.dopossess)
local selfbot
script.Parent.Touched:Connect(function(hit)
	if replicatedStorage.possession_settings.possessor_enabled.Value == false then
		script.Parent:Destroy()
		return
	end
	if hit.Parent:FindFirstChild("ung_bot") then
		selfbot = hit.Parent.Name
		botname.Value = selfbot
		script.Parent:Destroy()
		if not hit.Parent:FindFirstChild("canbepossessed").Value then
			local cantpossess = replicatedStorage.possession_effects.cannot_possess.PossessionAttachment:Clone()
			cantpossess.Parent = hit.Parent.HumanoidRootPart
			local redlight = Instance.new("PointLight")
			redlight.Parent = cantpossess
			redlight.Color = Color3.fromRGB(255, 0, 4)
			redlight.Enabled = true
			redlight.Shadows = true
			redlight.Brightness = 3
			redlight.Range = 25
			task.wait(5)
			cantpossess:Destroy()
			redlight:Destroy()
			return 
		end		
		possessmodule.destroyPossess(player2) -- but there, "player2" is unknown. WHY?!?!?!?!?
		bte:Fire(player2)
	elseif hit.Parent:FindFirstChild("ung_3dbot") then
		local cantpossess = replicatedStorage.possession_effects.cannot_possess.PossessionAttachment:Clone()
		cantpossess.Parent = hit.Parent.HumanoidRootPart
		local redlight = Instance.new("PointLight")
		redlight.Parent = cantpossess
		redlight.Color = Color3.fromRGB(255, 0, 4)
		redlight.Enabled = true
		redlight.Shadows = true
		redlight.Brightness = 3
		redlight.Range = 25
		task.wait(5)
		cantpossess:Destroy()
		redlight:Destroy()
		return
	else
		return
	end
end)

MODULE (function):

function module.destroyPossess(plr:Player)
	if rs.possession_settings.one_time_use.Value then
		if not plr.Character:FindFirstChild("possessor") then
			plr.Backpack:WaitForChild("possessor"):Destroy()
		else
			plr.Character:FindFirstChild("possessor"):Destroy()
		end
	end
end

From the module script you sent, I can’t see return keyword in it. If you require a module script with no return keyword in it, it will always return nil and it will just run the code inside the module script. Maybe that’s the problem?

Correct code:

return function module.destroyPossess(plr:Player)
	if rs.possession_settings.one_time_use.Value then
		if not plr.Character:FindFirstChild("possessor") then
			plr.Backpack:WaitForChild("possessor"):Destroy()
		else
			plr.Character:FindFirstChild("possessor"):Destroy()
		end
	end
end

nope, that is not the problem, if i do this function in same server script, it anyway will throw an error

They likely return the ‘module’ table at the end of the script.

Add print(plr) to the function to make sure it isn’t ‘nil’.

when server gets fire and player name, server knows it, but when touched function performed - player no longer “exists” for script

possessmodule.destroyPossess(player2) -- but there, "player2" is unknown. WHY?!?!?!?!?
Add print(player2.Name) before this line.