Player humanoid

so i have a script that is making my character into the npc’s character when I press e, and if my character is in the npc, it changes me back to my character when I press e again.
but I am getting this error:


here’s the script:

local UIS = game:GetService("UserInputService")
local Character = script.Parent
local Npc = game.Workspace.Npc
local camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer


UIS.InputBegan:Connect(function(Key, Chatted)
	if Chatted then
		return
	end
	if Key.KeyCode == Enum.KeyCode.E and Player.Character == Character then 
		camera.CameraSubject = Npc
		Player.Character = Npc
	else
		Player.Character = Player.HumanoidRootPart
		camera.CameraSubject = Player.Humanoid
										
	end



end)

you get the HumanoidRootPart from the character not the player

You’d want to use Player.Character.Humanoid(RootPart) or Character.Humanoid(RootPart) in the else clause. You’re trying to get the humanoid and the root part from the player instance itself rather than the player’s character.

HumanoidRootPart not Humanoid(RootPart)

I typed it this way because the post author has two invalid lines, one of them having HumanoidRootPart and the second one having Humanoid.

so do i do Player.Character? or other stuff

As I said, either replace = Player. with = Player.Character. or = Character. (given the fact the script is a direct child of the character, since you defined Character to be the script’s parent).