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

issue with tables?

Asked by 8 years ago

so im creating a player detection system to check who's still alive

i insert a boolean value into each player

problem is it's not adding them to the table or something because the round ends because it doesn't find anything in my active players table ;(

here's my relevant code

for _, plyr in pairs(playerTable) do

        local char              =  plyr.Character

        local torso         =  char:WaitForChild("Torso")

        local activetag             = Instance.new("BoolValue")
        activetag.Parent = char
        activetag.Name = "activetag"

        local spawnto       =  spawntable[math.random(1,#spawntable)]

        torso.CFrame = CFrame.new(spawnto.Position)

        spawnto:remove()

        wait()

    end


    sTag.Value = "ingame"

    aTag.Value = "Game in progress"

    while timetag.Value > 0 do
        wait(1)
        timetag.Value = timetag.Value - 1
        local activeplayers = {}
        for _, player in pairs(game.Players:GetPlayers()) do
            local char = player.Character
            local activetag = char:findFirstChild("activetag")
            if activetag then
                table.insert(activeplayers, player)
            end
            print(#activeplayers)
            if #activeplayers <= 0 then --if the number of active players is less than or equal to a certain number, then end the round.
                break
            end
        end
    end

    aTag.Value = "The round is over."

    wait(3)

    wait()

end

1 answer

Log in to vote
-1
Answered by 8 years ago

Ahmed7661 ~ On line 13 you made a mistake. The correct line is : torso.CFrame = CFrame.new(spawnto.CFrame)

Quest :



01 for _, plyr in pairs(playerTable) do 02 03 local char = plyr.Character 04 05 local torso = char:WaitForChild("Torso") 06 07 local activetag = Instance.new("BoolValue") 08 activetag.Parent = char 09 activetag.Name = "activetag" 10 11 local spawnto = spawntable[math.random(1,#spawntable)] 12 13 torso.CFrame = CFrame.new(spawnto.Position) 14 15 spawnto:remove() 16 17 wait() 18 19 end 20 21 22 sTag.Value = "ingame" 23 24 aTag.Value = "Game in progress" 25 26 while timetag.Value > 0 do 27 wait(1) 28 timetag.Value = timetag.Value - 1 29 local activeplayers = {} 30 for _, player in pairs(game.Players:GetPlayers()) do 31 local char = player.Character 32 local activetag = char:findFirstChild("activetag") 33 if activetag then 34 table.insert(activeplayers, player) 35 end 36 print(#activeplayers) 37 if #activeplayers <= 0 then --if the number of active players is less than or equal to a certain number, then end the round. 38 break 39 end 40 end 41 end 42 43 aTag.Value = "The round is over." 44 45 wait(3) 46 47 wait() 48 49 end
0
that has nothing to do with what i was asking and no, it wasn't a mistake. the teleportation system works just fine thank you. anyway, i fixed the issue. dirty_catheter 7 — 8y
Ad

Answer this question