SetSubject is not a valid member of ReplicatedStorage "ReplicatedStorage"

My error is

  17:59:03.473 - SetSubject is not a valid member of ReplicatedStorage "ReplicatedStorage"

My script is

local SetSubject = game.ReplicatedStorage.SetSubject

function onEvent_SetSubject(Humanoid)
	workspace.CurrentCamera.CameraSubject = Humanoid
end

SetSubject.OnClientEvent:Connect(SetSubject)

and the SetSubject is in Rep
image

Maybe try

SetSubject.OnClientEvent:Connect(onEvent_SetSubject)

because it seems like you’re trying to bind the event to the variable instead of the function

I suggest doing a :WaitForChild on SetSubject. This is probably a race condition issue.

1 Like

Change lines 1 and 3 to the following:

local SetSubject = game.ReplicatedStorage:WaitForChild("SetSubject")

function SetSubject(Humanoid)

I don’t know why your function starts with ‘onEvent’, as it’s not required and isn’t a function. Also, waiting for your variable instead of just referencing it ensures that if other scripts fire your event before you’ve referenced it, it’s not going to return an error.

1 Like

Use a :WaitForChild(), it might not be in ReplicatedStorage yet, if that does not work, are there any other scripts interfering with this? Is there a script that is moving and/or deleting?