So certain items on my game have individual level multipliers. For example a sword can have a base damage of 50, and the level multiplier would be 1.1, so if the sword level was higher than 1, it would multiply the base damage by 1.1, if it was level 2 it would multiply it again. But in order to do this I would need to loop it.

local baseDamage = 50
local levelMultiply = 1.1
local level = 3

if level > 1 then
for i = 1, level - 1 do
baseDamage = baseDamage * levelMultiply
end
end

This script may not even function as I am writing this on mobile hence the lack on indents. Level minuses 1 because I do not want the multiplier to function until the item is at level two and then begin to multiply the 1.1

5 comments

0

baseDamage = (baseDamage * levelMultiply) ^ (level - 1) I think is it, I might be wrong.

1

baseDamage = baseDamage * levelMultiply ^ (level - 1) Pejorem I think there shouldn't be a bracket so only the levelMultiply gets exponent

0

What does ^ mean? Is it a mathematical operation?

2

it is the same as math.pow

0

Jesus guys, would it kill ya to post answers in the answer section and not the comments?