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

How do I insert a player into another table?

Asked by 9 years ago

Here's the code. ** Error on line 15.** I want to put a countdown in the players of the "current" table.

--Made by Aceta

players = game.Players:GetPlayers()
local piece = Workspace.teleportationpart
local map = Workspace.Map
current = {}

function teleportPlayers()
    for i, v in pairs(players) do
        if v.play.Value == true then
            v.Character.Torso.CFrame = CFrame.new(piece.Position+Vector3.new(
                math.random(1,10),
                math.random(2,6),
            math.random(1,10)))
            table.insert(v,current)
        end
    end
end

function countdown()
    for i, v in pairs(current) do
        local stats = v.PlayerGui.fullGui.everything.gamePlay.informer
        stats.Text = '3'
        wait(1)
        stats.Text = '2'
        wait(1)
        stats.Text = '1'
        wait(1)
        stats.Text = 'Begin!'
        stats.FontSize = 'Size48'
    end
end

2 answers

Log in to vote
0
Answered by 9 years ago

And...Fixed.

--Made by Aceta

players = game.Players:GetPlayers()
local piece = Workspace.teleportationpart
local map = Workspace.Map
current = {}

function teleportPlayers()
    for i, v in pairs(players) do
        if v.play.Value == true then
            v.Character.Torso.CFrame = CFrame.new(piece.Position+Vector3.new(
                math.random(1,10),
                math.random(2,6),
            math.random(1,10)))
            table.insert(current, v.Name)
        end
    end
end

function countdown()
    for i, v in pairs(current) do
        local stats = game.Players:FindFirstChild(v).PlayerGui.fullGui.everything.gamePlay.informer
        stats.Text = '3'
        wait(1)
        stats.Text = '2'
        wait(1)
        stats.Text = '1'
        wait(1)
        stats.Text = 'Begin!'
        stats.FontSize = 'Size48'
    end
end
teleportPlayers()
countdown()
Ad
Log in to vote
0
Answered by 9 years ago

When you use table.insert, the table goes first, then the element. So the correct syntax would be table.insert(current,v) instead of table.insert(v,current). Hope this helped

Answer this question