I made a power and mod algorithm, here it is:
I have tried printing alot of stuff out but I cannot find what is causing the issue

function PowerWithMod(Base, Exponent, Modulo)
local resault = 1
for i = 31, 0, -1 do
resault *= resault
resault %= Modulo
if bit32.extract(Exponent, i, 1) == 1 then
resault *= Base
resault %= Modulo
end
end
return resault
end

It’d help if you mentioned what you expect to happen, and what is actually happening.
I can see 1 issue with the math here though. if bit32.extract(Exponent, i, 1) == 1 then
won’t work if you get floating point errors and the answer = 1.00000001 or .999999999
You could try > .99999 and < 1.00001

Also I’m not exactly sure what the math of that line does, but if i gets to 0 does it crash the calculation? By that I mean that if anything gets divided by 0 it produces an error.

I am not getting any floating point numbers from it, it does not give any errors, it just gives the wrong number. Additionally the bit32 library should work fine as the number should never have more then 24 bits.