Converting C# to Roblox lua?

Hello, I was wondering if it’s possible to convert C# (the coding that unity uses) to Roblox LUA.
If I posted this in the wrong topic, my bad.

Reason why I want a converter

Camera shaker

public class CameraEffects : MonoBehaviour {
   
    public GameObject object;
    Vector3 setPosition;
    float minPerlin = -1.0f, maxPerlin = 1.0f;
   
    // Use this for initialization
    void Start ()
    {
        setPosition = transform.position;
    }
   
    // Update is called once per frame
    void Update ()
    {
       
        Vector3 newPos;
       
        newPos = setPosition;
       
        newPos.x =  Mathf.PerlinNoise( newPos.x * minPerlin, newPos.x * maxPerlin);
        newPos.y =  Mathf.PerlinNoise( newPos.y * minPerlin, newPos.y * maxPerlin);
       
        transform.position = newPos;
    }
}
Best I can do
local minPerlin = -1.0;
local maxPerlin = 1.0;
local camera = workspace.CurrentCamera

function Update()
    camera.CFrame = math.noise(camera.CFrame.X*minPerlin,camera.CFrame.Y*maxPerlin);
end


for i = 1, 200 do
	wait()
	Update()
end
2 Likes

I suppose it might be possible to transpile it. (Would need modification to remove built in Lua libraries)

But why would you want to do that?

Converting C# directly to Lua is not very difficult but there is no automated way to accomplish this. Most of the C# language is very similar to lua so I recommend checking this out: https://developer.roblox.com/en-us/api-reference Unity and roblox use different styles of referencing objects so get familiar with both and you will be able to convert code easily.

I am sure in Visual Studio you can kinda ‘mix’ the languages, but I don’t really understand why you would do this. Would not you already write stuff in Lua?

Roblox made a whole comparison which you could base off of:

You could work on your own compiler or re-write them ino Lua.

4 Likes