There's nothing in the output about this, please point out my error/s.
Players.PlayerAdded:Connect(function(player) PlayerCount.Value = PlayerCount.Value + 1 print(PlayerCount.Value) print(player.Name + "has joined the game") end)
use ".." instead of "+"
so it should look like this:
game.Players.PlayerAdded:Connect(function(player) -- btw don't forget the define to game PlayerCount.Value = PlayerCount.Value + 1 print(PlayerCount.Value) print(player.Name.."has joined the game") end)
you forgot your local variable.
local PlayerCount.Value = 0 game.Players.PlayerAdded:Connect(function(player) PlayerCount.Value = PlayerCount.Value + 1 print(player.Name.." has joined the game") end)
if you want to use a intvalue instead
add a intvalue into workspace and name it PlayerCount. then do this script.
local PlayerCount = workspace.PlayerCount game.Players.PlayerAdded:Connect(function(player) PlayerCount.Value = PlayerCount.Value + 1 print(player.Name.." has joined the game") end)
When testing in studio, your player connects before any Scripts are run. This means PlayerAdded events will never be fired. It is recommended to write fallbacks for any PlayerAdded events.
Example
local RunService = game:GetService("RunService") local Players = game:GetService("Players") function playerAdded(callback) if RunService:IsStudio() then callback() else Players.PlayerAdded:Connect(callback) end end playerAdded(function() print("fallback working") end)
Also ..
congregates strings not +