# Player Winner in Event.

#### lSenturion2

##### Member
Hello my friends, I wanted to ask you a huge favor, if someone has a script for when there is only one player in a specific area, only this player is teleported to a position.

Example: I won the event "The last man standing" and when I was the only player in that area, I teleported to a position where the rewards will be.

Thanks a lot !

PD: It doesn't matter if it's Globalevent, Action, Movement ... I just want if there is 1 player in the area, it is teleported.

Solution
Lua:
``````local area = {{x = 100, y = 100, z = 7}, {x = 105, y = 105, z = 7}} -- from, to

local playersInArea = {}
local pos
for _, pid in ipairs(getPlayersOnline()) do
pos = getThingPosition(pid)
if pos.x >= area.x and pos.y >= area.y and pos.z >= area.z and pos.x <= area.x and pos.y <= area.y and pos.z <= area.z then
table.insert(playersInArea, pid)
end
end

if #playersInArea == 1 then
doTeleportThing(playersInArea, {x = 200, y = 200, z = 7}) -- teleport location
end``````

#### Xikini

##### I whore myself out for likes
Support Team
Untested, but should work.

Put this wherever you need it.

Lua:
``````local area = {Position(100, 100, 7), Position(105, 105, 7)} -- from, to

local playersInArea = {}
for _, targetPlayer in ipairs(Game.getPlayers()) do
if targetPlayer:getPosition():isInRange(area, area)
table.insert(playersInArea, targetPlayer:getId())
end
end

if #playersInArea == 1 then
local player = Player(playersInArea)
player:teleportTo(Position(200, 200, 7)) -- teleport location
end``````

OP
OP
L

#### lSenturion2

##### Member
Hello, Sorry I have TFS 0.4 can you do it again please?

#### Xikini

##### I whore myself out for likes
Support Team
Lua:
``````local area = {{x = 100, y = 100, z = 7}, {x = 105, y = 105, z = 7}} -- from, to

local playersInArea = {}
local pos
for _, pid in ipairs(getPlayersOnline()) do
pos = getThingPosition(pid)
if pos.x >= area.x and pos.y >= area.y and pos.z >= area.z and pos.x <= area.x and pos.y <= area.y and pos.z <= area.z then
table.insert(playersInArea, pid)
end
end

if #playersInArea == 1 then
doTeleportThing(playersInArea, {x = 200, y = 200, z = 7}) -- teleport location
end``````

• zezin009 and Levi999x
OP
OP
L

#### lSenturion2

##### Member
It works perfectly , thanks so much you are god in this 