Welcome, I’m working on an in-game “server” system where everytime a player joins a folder which has a NumberValue as a child gets cloned, that NumValue then gets the ID of the player that just joined pasted into it.
It does get cloned, but not all the times, sometimes when I start a test with 3 Players only gets 1 folder cloned. The first player to join also seems to not get his folder cloned, same happens if I try on Roblox player.
local ServerData = game.ReplicatedStorage.MenuData.Servers
local player = game.Players.PlayerAdded:Wait()
local function generateServerCode()
return string.format("%X", math.random(0, 0xFFFFFF))
end
local function joinServer(player, x)
local serverCode = generateServerCode()
local playerFolder = player:FindFirstChild("leaderstats")
local templateServerFolder = ServerData.ServerCode:Clone()
templateServerFolder.Value = serverCode
templateServerFolder.Parent = ServerData
local player1Value = templateServerFolder:FindFirstChild("Player1")
local UI = player.PlayerGui
if player1Value then
player1Value.Value = player.UserId
end
UI.MenuUi.MenuFrame.VPFme1.UserID.Value = player.UserId
end
game.Players.PlayerAdded:Connect(function(player)
print("A")
joinServer(player)
print("B")
end)
Hierarchy: