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

map chooser and player teleport won't work?

Asked by 8 years ago
local storage = game.ServerStorage
local minigame = storage:WaitForChild("minigames")
local holder = game.Workspace.mapHolder
local currentGame = holder:GetChildren()
local intermissionTime = 30
local roundTime = 60 * 3
local people = game.Players:getChildren()


while true do
if #people >= 2 then
    for i, object in pairs(game.Players:GetChildren()) do
        local character = object.Character
        local mapSpawns = currentGame:FindFirstChild("Spawns"):GetChildren()
        local torso = object:FindFirstChild("Torso") 
        local humanoid = character:FindFirstChild("Humanoid")
        local sword = storage.Sword:clone()
        local allMaps = minigame:GetChildren()
        local map = minigame:GetChildren(math.random(1, #allMaps))
        map.Parent = holder
        if currentGame.Name == "swordFight" then
            sword.Parent = object.Backpack
        end
        torso.CFrame = CFrame.new(mapSpawns.Position + Vector3.new(0,3,0))
        character.Parent = currentGame
        if humanoid.Health == 0 then
            character.Parent = game.Workspace
        end
    end
end


wait(intermissionTime)
end



Lots of code, and I'm pretty sure I did a good bit of it correct? Please just try to refrain from mocking me in the comments if it's obviously wrong, this is my first try at something like this. But the problem is it won't spawn in the map, not sure where I went wrong with it? Thanks for all the help lately guys!

1 answer

Log in to vote
1
Answered by
FiredDusk 1466 Moderation Voter
8 years ago
local storage = game.ServerStorage
local minigame = storage:WaitForChild("minigames")
local holder = game.Workspace.mapHolder
local currentGame = holder:GetChildren()
local intermissionTime = 30
local roundTime = 60 * 3
local people = game.Players:getChildren()


while true do
if #people >= 2 then
    for i, object in pairs(people) do --I am guessing you can just put "people" here since you made a variable already.
        local character = object.Character
        local mapSpawns = currentGame:FindFirstChild("Spawns"):GetChildren()
        local torso = object:FindFirstChild("Torso") 
        local humanoid = character:FindFirstChild("Humanoid")
        local sword = storage.Sword:clone()
        local allMaps = minigame:GetChildren()
        local map = minigame:GetChildren(math.random(1, #allMaps))
        map.Parent = holder
        if currentGame.Name == "swordFight" then
            sword.Parent = object.Backpack
        end
        torso.CFrame = CFrame.new(mapSpawns.Position + Vector3.new(0,3,0))
        character.Parent = currentGame --And I am not sure but maybe you would need a posistion here.
        if humanoid.Health == 0 then
            character.Parent = game.Workspace
        end
    end
end


wait(intermissionTime)
end

I am just a basic scripter, just here (trying) to help.

Ad

Answer this question