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:
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’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.
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).