Script:
amountofPlayers = workspace.Server.Players.Value
game.Players.PlayerAdded:Connect(function(player)
amountofPlayers = amountofPlayers + 1
end)
Script:
amountofPlayers = workspace.Server.Players.Value
game.Players.PlayerAdded:Connect(function(player)
amountofPlayers = amountofPlayers + 1
end)
Pointers don't exist in Lua, you've simply just allocated the Value's state into
amountofPlayers. If you want to change the property, you'll have to index it each time
--// This is what's actually happening.
amountofPlayers = workspace.Server.Players.Value
(amountofPlayers = 5) --// [Per say]
You need to:
local Players = game:GetService("Players")
local AmountOfPlayers = workspace.Server.Players
Players.PlayerAdded:Connect(function()
AmountOfPlayers.Value += 1
end)
You should also know, that you can determine the number of Players in-game this way:
local Players = game:GetService("Players")
print(#Players:GetPlayers()) --> 5
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Pointers don't exist in Lua, you've simply just allocated the Value's state into amountofPlayers. If you want to change the property, you'll have to index it each time.
Sorry, I'm pretty dumb in terms of code. Could you simplify it?