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

Why can't I print from ServerScriptService?

Asked by 3 years ago
function load_desert()
    local alive = {}
    for i,k in pairs(Players) do
        table.insert(alive,k.Name)
        print("added")
    end
    local squares = workspace.desert.Model.squares:GetChildren()    
    for i,k in pairs(squares) do --ignore this
        k.Touched:Connect(function()
            k.Transparency = 0.5
            wait(1)
            k.Transparency = 1
            k.CanCollide = false
            wait(2.5)
            k.Transparency = 0.7
            wait(3)
            k.CanCollide = true
            k.Transparency = 0
        end)
    end
    game:GetService("Players").PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character)
            character:WaitForChild("Humanoid").Died:Connect(function()
                for i,k in pairs(alive) do
                    if k.Name == player.Name then
                        table.remove(alive, i)
                        print("died")
                    end
                end
            end)
        end)
    end)
end

load_desert()

This code is supposed to add the players to a list and then if a player dies, he's removed from the list. But the messages added and died aren't printed.

Any suggestions?

0
anyone? TheChi_1705 22 — 3y
0
Does the code actually run in the loop? CrypxticDoge 135 — 3y
0
what do you mean? there are 2 for loops, the second one is for something else. The first one should iterate through players and add them in a list TheChi_1705 22 — 3y

Answer this question