Camera won't change position

I’m new to scripting and I’m practicing camera manipulation. My goal is to have the local player’s camera focus on a part after triggering the proximity prompt attached to it. I didn’t get any exceptions while running the game but my script isn’t working.

Server Script:

local r_storage = game:GetService("ReplicatedStorage")
local switch = r_storage.forCamera.RemoteFunctions.Switch
local object = script.Parent


object.Attachment.ProximityPrompt.Triggered:Connect(function(player)
	switch:FireClient(player, object)
end)

Local Script:

local player = game:GetService("Players").LocalPlayer
local humanoid = player.CharacterAdded:wait():WaitForChild("Humanoid")
local r_storage = game:GetService("ReplicatedStorage")
local switch = r_storage.forCamera.RemoteFunctions.Switch
local camera = workspace.CurrentCamera


switch.OnClientEvent:Connect(function(object)
	if humanoid.Health > 0 then 
		camera.CameraType = Enum.CameraType.Scriptable
		camera.Focus = object.CFrame
	end
end)
2 Likes

Try adding a print inside the OnClientEvent to check if the connection is being registered

Also I suggest to change this local humanoid = player.CharacterAdded:wait():WaitForChild("Humanoid")
to
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char :WaitForChild("Humanoid")

and camera.Focus = object.CFrame to camera.CFrame= object.CFrame

Is “switch” a RemoteFunction or RemoteEvent?