How do i make something tilt back and forth in 2d space?

How do i get an object to rock back and forth in 2d space? I’m thinking like it rotates one-way until it hits like 50 degrees, then it starts rotating the other way until it hits -50 degrees, then it starts rotating the other way and repeat. i am very new to C#, and help is appreciated!
here is my code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Wobble : MonoBehaviour
{
    int angle = 0;
    bool rotate = false;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (angle > 50)
        {
            rotate = true;
        }
        else if (angle < -50)
        {
            rotate = false;
        }
        if (rotate)
        {
            angle += 0;
        }
        else if (!rotate)
        {
            angle -= 0;
        }
        this.transform.Rotate(0,angle,0);
    }
}

using UnityEngine;
public class RotatePingPong : MonoBehaviour
{
    void Update()
    {
        float a=Mathf.SmoothStep(-50,50,Mathf.PingPong((Time.time/3)%2-0.5f,1.0f)); // 3 is the speed
        transform.eulerAngles=new Vector3(0,0,a);
    }
}

Thank you so much!!!
have a good day!!

quick question:
I’m trying to make it so that when i hit R the scene resets and the rotation of the Object resets. I’ve got the scene resetting down, but the rotation seems to be sticky.
here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Wobble2 : MonoBehaviour
{
    float a;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        a = Mathf.SmoothStep(-50, 50, Mathf.PingPong((Time.time / 7) % 2 - 0.5f, 1.0f)); // 3 is the speed
        transform.eulerAngles = new Vector3(0, 0, a);
        if (Input.GetKey(KeyCode.R))
        {
            a = 0;
        }
    }
}

It’s because the angle is taken from Time.time. Try replacing line 18 with this:

a = Mathf.SmoothStep(-50, 50, Mathf.PingPong((Time.timeSinceLevelLoad / 7) % 2 - 0.5f, 1.0f));