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

Script not printing out player name as it should?

Asked by
CodeWon 181
3 years ago

I was making some basic and random code and nothing happend when I ran it.

local players = {}

game.Players.PlayerAdded:Connect(function(player)
    table.insert(players, player.Name)
end)

for i, v in pairs(players) do
    if v.Name == "CodeWon" then
        print("Hello")
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago
local players = {}

game.Players.PlayerAdded:Connect(function(player)
       table.insert(players, player.Name)
       if player.Name == "CodeWon" then
             print("Hello")
       end
end)

This script should work.

Ad

Answer this question