Hi devs, does anyone know how to place a Folder in the Character of all players in the game?
I’m currently attempting to create a folder with values in it for all players, but it doesn’t seem to be working.
Serverscript
local Players = game:GetService("Players")
local function createFolderInCharacter(player)
local character = player.Character
if character then
local valuesFolder = Instance.new("Folder")
valuesFolder.Name = "Values"
valuesFolder.Parent = character
end
end
Players.PlayerAdded:Connect(createFolderInCharacter)
for _, player in ipairs(Players:GetPlayers()) do
createFolderInCharacter(player)
end
and here is a script that work on local but doesn’t work on server.
local ValuesFolder = Instance.new("Folder")
local TeamValue = Instance.new("StringValue")
local Coins = Instance.new("IntValue")
local Rubis = Instance.new("IntValue")
local Wins = Instance.new("IntValue")
ValuesFolder.Name = "Values"
TeamValue.Name = "Team"
Coins.Name = "Coins"
Rubis.Name = "Rubis"
Wins.Name = "Wins"
ValuesFolder.Parent = game:GetService("Players").LocalPlayer.Character
TeamValue.Parent = ValuesFolder
Coins.Parent = ValuesFolder
Rubis.Parent = ValuesFolder
Wins.Parent = ValuesFolder
local Players = game:GetService("Players")
local function createFolderInCharacter(character)
local ValuesFolder = Instance.new("Folder")
local TeamValue = Instance.new("StringValue")
local Coins = Instance.new("IntValue")
local Rubis = Instance.new("IntValue")
local Wins = Instance.new("IntValue")
ValuesFolder.Name = "Values"
TeamValue.Name = "Team"
Coins.Name = "Coins"
Rubis.Name = "Rubis"
Wins.Name = "Wins"
ValuesFolder.Parent = character
TeamValue.Parent = ValuesFolder
Coins.Parent = ValuesFolder
Rubis.Parent = ValuesFolder
Wins.Parent = ValuesFolder
end
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(createFolderInCharacter)
end
for _, player in ipairs(Players:GetPlayers()) do
player.CharacterAdded:Connect(createFolderInCharacter)
end
I noticed that earlier, however it is something I have had to add to my own scripts before. It’s mainly just for testing in studio, when the player object is added faster than the script reaches the connection.