Roblox Script Detect new Players in the game
Posted on April 26, 2020
This script will run a function for each new Player in the game:
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print("new Player:", player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
and here the code to performe some action on each current Player in the game:
local Players = game:GetService("Players")
for i, player in pairs(Players:GetPlayers()) do
local character = player.Character
if character then
local humanoid = character.Humanoid
-- do something with the player, the character or the humanoid
end
end