Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Reverting the camera back?

script.Parent.MouseButton1Click:connect(function()
	if script.Parent.bool.Value==false then
		local target = workspace.Model.point1
		local camera = workspace.CurrentCamera
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CameraSubject = target
		camera.CoordinateFrame = CFrame.new(target.Position+Vector3.new(0,3,4),workspace.Model.point1.Position)
		script.Parent.bool.Value=true
		print("na")
	else
		print("ye")
		local plr=game.Players.LocalPlayer.Name
		local camera=workspace.CurrentCamera
		camera.CameraSubject=workspace[plr].Humanoid
		script.Parent.bool.Value=false
	end
end)

Yes so I want to make it so the camera goes to the part(which works). But I then want to make it so if you click the button again the camera reverts back to the humanoid but this part doesnt work. It prints ye so I am not sure what the problem is.

1 answer

✓ Accepted answer

Set The CameraType to "Custom"

Custom is the default camera type used in game on the Humanoids. If you leave it as scriptable, you have to change the CFrame to move it.

script.Parent.MouseButton1Click:connect(function()
    if script.Parent.bool.Value==false then
        local target = workspace.Model.point1
        local camera = workspace.CurrentCamera
        camera.CameraType = Enum.CameraType.Scriptable
        camera.CameraSubject = target
        camera.CoordinateFrame = CFrame.new(target.Position+Vector3.new(0,3,4),workspace.Model.point1.Position)
        script.Parent.bool.Value=true
        print("na")
    else
        print("ye")
        local plr=game.Players.LocalPlayer.Name
        local camera=workspace.CurrentCamera
        camera.CameraSubject=workspace[plr].Humanoid
        camera.CameraType = Enum.CameraType.Custom
        script.Parent.bool.Value=false
    end
end)
If I helped, please don't forget to accept my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.