Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleport All Players within Boundaries in Map Changing Script [FIX NEEDED] Help?

Asked by
Moxeh 84
10 years ago

This what was in the output: 08:41:04.871 - Workspace.Map Changer:7: bad argument #2 to 'random' (interval is empty) 08:41:04.872 - Script 'Workspace.Map Changer', Line 7 - local TeleportPlayer 08:41:04.873 - Script 'Workspace.Map Changer', Line 25 08:41:04.873 - Stack End

local MaxTele = Vector2.new(106, -371)
local MinTele = Vector2.new(66, -332)
local TeleHeight = 70.814

local function TeleportPlayer(Player)
    if Player and Player.Character and Player.Character:FindFirstChild("Torso") then
        local Position = Vector3.new(math.random(MinTele.X,MaxTele.X),TeleHeight,math.random(MinTele.Y,MaxTele.Y))
        Player.Character:MoveTo(Position)
    end
end


while true do
    wait(10)--Map time (300)
    local modelGroup = game.ReplicatedStorage:FindFirstChild("Maps"):GetChildren()
    local PickedModel = modelGroup[math.random(1, #modelGroup)]
    local Model = PickedModel:Clone()
    if game.Workspace:FindFirstChild("Map") then

    game.Workspace.Map:Destroy()
    end
    --Teleport players to area (LOCAL DEFINITIONS)

    for i,v in pairs(game.Players:GetPlayers()) do
        TeleportPlayer(v)
    end

    wait(5)
    for i, v in pairs(game.Players:GetChildren()) do
    v:LoadCharacter() end

    wait(1)

    Model.Parent = game.Workspace


    end
--[[local MaxTele = Vector2.new(239, 688)
local MinTele = Vector2.new(229, 679)
local TeleHeight = 157.1

while true do
    wait(10)--Map time (300)
local modelGroup = game.ReplicatedStorage:FindFirstChild("Maps"):GetChildren()
local PickedModel = modelGroup[math.random(1, #modelGroup)]
local Model = PickedModel:Clone()
if game.Workspace:FindFirstChild("Map") then

    game.Workspace.Map:Destroy()
end
--Teleport players to area (LOCAL DEFINITIONS)

wait(5)
    for i, v in pairs(game.Players:GetChildren()) do
    v:LoadCharacter() end

wait(1)

Model.Parent = game.Workspace


end--]]

1 answer

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

I would look into using Region3 and FindPartsInRegion3 to find all of the characters in a region.

0
Not within a region, within the entire server. Moxeh 84 — 10y
Ad

Answer this question