Why does setting this Camera CFrame kill the player?

I’m testing camera positions using buttons, and one of them kills the player. (More specifically, it seems like the player’s model is being moved to NaN for some reason.)

--!strict

local camera = workspace.CurrentCamera

-- This one kills the player.
script.Parent.CameraPos1.MouseButton1Click:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = CFrame.new(-183, 450.830688, 43.5, -0, 0.99999994, -0, 0, 0, 0.99999994, 1, 0, -0)
end)

script.Parent.CameraPos2.MouseButton1Click:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = CFrame.new(-183, 450, 43.5)
end)

script.Parent.CameraPos3.MouseButton1Click:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = CFrame.new(-183, 450, 43.5, -0, 1, -0, 0, 0, 1, 1, 0, -0)
end)

script.Parent.Reset.MouseButton1Click:Connect(function()
	camera.CameraType = Enum.CameraType.Custom
end)

Only the first position kills the player. The CFrame value I use was generated by a script.

I couldn’t find any info on this, and I’m unsure as to if I should report it as a bug?


test place.rbxl (55.2 KB)

Are you sure that cameratype actually changes? Sometimes it dont want to change you can use print to check.

script.Parent.CameraPos1.MouseButton1Click:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = CFrame.new(-183, 450.830688, 43.5) * CFrame.Angles(math.rad(-90), 0, 0)
end)

The error in the CameraPos1 line was an invalid rotation matrix in CFrame.new(-183, 450.830688, 43.5, -0, 0.99999994, -0, 0, 0, 0.99999994, 1, 0, -0), which wasn’t orthonormal, causing NaN and “killing” the player.

2 Likes

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