I'm making a Mario like platformer level editor and I'm currently working on customizable enemies and objects. But when an enemy transforms it should have the same movespeed that it had before. But for some reason, it gets set to nil.
local transformedfrom = obj.transformedfrom
local koopa = OBJECTS:transform(i, obj, 16)
koopa.vx = 0
koopa.vy = 0
koopa.invincframes = 14
print(transformedfrom[2].mvspd) --prints 4
koopa.mvspd = transformedfrom[2].mvpsd --for some reason koopa.mvspd gets set to nil instead
if obj.x > PLAYER.x then
koopa.facing = -1
else
koopa.facing = 1
end
if obj == PLAYER.holding then
PLAYER:die()
end
obj.type = "dead" --deletes the original object