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)
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)
I hope it works now
Yes this is right you probally got confused with c#
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)
#Studio Load Order
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 +
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
This can't be your only code, show us your variables.
u can try to make a variable of the playername local name = player.Name
Player parameter is set. It is useless to set another variable locate it player.Name if it's once use. Variables aren't important
How are you testing this? in studio?