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

Cloning into a table?

Asked by 10 years ago

It's supposed to clone the children of Officer into the players that are cops. Help would be appreciated

local Hunters = {}
local Cops = {}

local Officer = game.Workspace.Characters.Officer:GetChildren()

local Players = game.Players:GetChildren()

for i,v in pairs(Players) do
table.insert(Hunters,v)
end

function chooseRandomPlayer(fromTeam,toTeam)
    local randomPlayer = nil
    repeat
        randomPlayer = fromTeam[math.random(1,#fromTeam)]
    until randomPlayer
    table.insert(toTeam,randomPlayer)
    for i,v in pairs(Players) do
        if v.Name == randomPlayer.Name then
        for z,b in pairs(Players) do
            if (b.className == "Hat") or (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
                b:Remove()
            end
            if Cops then
                Officer.Parent = Cops
            end
        end
        table.remove(fromTeam,i)
    end
end
end
chooseRandomPlayer(Hunters, Cops)
0
Please explain what you want the code to do. At a glance, it's not really possible to determine what you *expect* is supposed to happen. adark 5487 — 10y
1
there edited it to explain better. TREVOR818730 25 — 10y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Try this in place of lines 24-26:

for _, cop in Cops do
    for _, bit in Officer do
        bit:Clone().Parent = cop
    end
end
0
I'm not checking to see if it exist, I'm trying to clone the charactermeshes and the hat into the players that are picked as cops. TREVOR818730 25 — 10y
Ad

Answer this question