Trying to change the camera got "attempt to index nil with CFrame"

I’m trying to change the camera when you step on a part using a remote event

I’m getting the error “attempt to index nil with CFrame”

my script

cameraeventS.OnClientEvent:Connect(function(plr, cam)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = cam.CFrame
	return cam
end)

local script ^

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		wait(0.25)
		cameraevent:FireClient(plr, house1cam1)
		plr.Character.HumanoidRootPart.CFrame = entrance.CFrame*CFrame.new(0,5,0)
	end
end)

server script ^

whats cam (like try printing it)

when I print cam it says that cam is equal to nil

check what youre firing on the client event

I’m trying to fire a part to the client for the camera, but I’m now seeing its not working

imma guess that when you fire client your parameters are like this?

(player , cam)?

yea that is exactly what im doing

try removing the plr, on this

3 Likes

thank you so much dude, you’re a big help

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.