Hello! So in this server script, I want it to make it where each player has their value inside of a folder in ServerStorage unless the player has a value inside a player called, “OutOfGame”. The value will be in another script, but I won’t show it because it is off topic. Here is the script:
local function peopleingame()
local playerfolder = game.ServerStorage.PlayerInGame
for i, v in pairs(game.Players:GetPlayers()) do
if not v:FindFirstChild("OutOfGame") then
local playervalue = Instance.new("ObjectValue")
playervalue.Name = v
end
end
end
So I always feel like it is only going to print one value, and there is going to be in error going into my output, but if you have any ideas, please comment below!
I never said that nor do I get what you’re meaning. pairs() iterates over every index in a table, unordered. ipairs() iterates over every index which is a number, in order.
17:34:27.091 - ServerScriptService.MainScript:36: bad argument #3 to 'Name' (string expected, got Object)
script:
local function peopleingame()
local playerfolder = game.ServerStorage.PlayerInGame
for i, v in ipairs(game.Players:GetPlayers()) do
if not v:FindFirstChild("OutOfGame") then
local playervalue = Instance.new("ObjectValue")
playervalue.Name = v
playervalue.Parent = playerfolder
print(playervalue.Name)
end
end
end