I am currently trying to make the camera face something via a toggle function script.
Upon clicking the Image button, the camera works properly on both X and Z axis, however, the Y axis drops my camera about 400 studs below the baseplate despite the camera’s Y value being scripted to go to 10.
Here is the video of this happening:
I looked through many dev forum posts but I could not find a single one with the answer I was looking for.
For reference, here is the code I used.
local button = script.Parent
local camera = game.Workspace.CurrentCamera
local cameraPart = game.Workspace.Nothingtron:WaitForChild("CameraPart")
local function changeCam(toggle)
camera.CameraType = (toggle and Enum.CameraType.Scriptable or Enum.CameraType.Custom)
camera.CFrame = (toggle and cameraPart.CFrame or CFrame.new(0, 0, 0))
end
button.MouseButton1Click:Connect(function()
button:SetAttribute("Toggled", not button:GetAttribute("Toggled"))
changeCam(button:GetAttribute('Toggled'))
end)
Any help that you can give me is appreciated. This is driving me crazy.