Simple thing : I need a way to solve different equations through a script, my simple example :

```
300 * x = 60 -- I need x solved, the 300 can be anything.
```

Simple thing : I need a way to solve different equations through a script, my simple example :

```
300 * x = 60 -- I need x solved, the 300 can be anything.
```

x = 60/300

so x = 0.2

300 * 0.2 = 60

or 300/5 = 60

1 Like

I donâ€™t need the equation from above solved, I need to know how i can always calculate different numbers. As said, the 300 from above only is an example.

Do you mean something like this?

```
local a = 300
x = 60/a
```

I remember seeing someone asking the exact question in the Scripting Helpers discord a couple of days ago, maybe it was you.

This is very simply, just convert the equation into a function, where the knowns are parameters and the unkown is the returned value.

```
function solve(a, c)
return c/a
end
--coonvert the equation 300*x=60 into x = 60/300
local x = solve(300, 60)
--make sure the parameters are alligned perfectly
--the equation a*b=c will become b = solve(a, c) where a and c are the known constants.
```

2 Likes

Wow, too sad I overlooked that, thanks you all though.

1 Like

But that wouldnâ€™t always work. What if you were doing multiple equations, you wanna be using functions for more efficiency, and not copy pasting lines. Also he didnâ€™t put 60 into a variable, he just wrote what incapaz wrote but put it inside of code blocksâ€¦

Yes, but the equation will always look like that, with only those 300 being anything.

I only needed that to properly calculate the firerate for a gun.

60 seconds / Shots per minute = delay between each shot