• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua [TFS 1.3] Teleport to a new floor

aqubjukr

Well-Known Member
Joined
Mar 13, 2013
Messages
200
Solutions
17
Reaction score
79
Location
Paraná, Brazil
I'm trying to get all monsters / players to be teleported to a floor below. (the current z =12 and I want them to be teleported to 11)

Lua:
local function changeGroundDown()
    local monsters = Game.getSpectators(Position(31724, 31556, 11), false, false, 20, 20, 20, 20)
    for _, monster in ipairs(monsters) do
    local oldPosition = monster:getPosition()
    local newPosition = Position({x = oldPosition.x, y = oldPosition.y, z = oldPosition.z - 1})
        monster:teleportTo(newPosition)
    end
end

The script works, the only part that isn't working is the spec: teleportTo (newPosition).

Any base scripts or tips are welcome.
Post automatically merged:

Omg, sorry.
I'm using -1.😤
 
Just do

Position({oldPosition.x, oldPosition.y, oldPosition.z - 1})


Do you get any errors in the console?

Are you sure your monsters variable is getting populated with anything?

Put a print() in there somewhere so you can see it's not just getting an empty array because of an issue with the pos of the getSpectators()
 
Back
Top