I’m currently making a system that detects if a friend has joined the game. I used game.Players.PlayerAdded as a way to detect it, but it only detects for the person already in the server, not for the one that joined the server. The script is in ServerScriptService, and I recall that game.Players.PlayerAdded function could work for the Player that was added to the game. Could someone help?
If you want it to also affect the player who just joined, I would suggest you duplicate the line starting with plr:FindFirstChild("PlayerBoosts"), and replace plr with player in the duplicate.
(Maybe use WaitForChild instead of FindFirstChild though)
i.e.
game.Players.PlayerAdded:Connect(function(player)
for _, plr in game.Players:GetPlayers() do
plr.PlayerBoosts.FriendBoost.Value += 0.1
player:WaitForChild("PlayerBoosts").FriendBoost.Value += 0.1
end
end