Character is not a valid member of Model when using camera manipulation

Server Script:

local plr = game.Players:GetPlayerFromCharacter(ehumanoid.Parent)
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireClient(plr,npc)

Client Script:

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnClientEvent:Connect(function(plr, npc)
	local Character = plr.Character
	local Camera = workspace.CurrentCamera
	local FocusPart = npc.Head
	
	repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
	until Camera.CameraType == Enum.CameraType.Scriptable
	Camera.CFrame = FocusPart.CFrame
end)

The output: [14:43:52.631 - Character is not a valid member of Model]

What did I do wrong and how can I fix it?

1 Like

When you’re connecting to your remote event on the client, you’re trying to get plr, and npc.

When it’s only passing in npc from the server.
In your local script you’ll need to get the player outside of the :Connect().

Client

local plr = game:GetService("Players").LocalPlayer;

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnClientEvent:Connect(function(npc)
	local Character = plr.Character
	local Camera = workspace.CurrentCamera
	local FocusPart = npc.Head
	
	repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
	until Camera.CameraType == Enum.CameraType.Scriptable
	Camera.CFrame = FocusPart.CFrame
end)
1 Like