Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I move player characters into a single folder?

Asked by 2 years ago

I had to take a break for a bit before coming back to scripting when I noticed one of my old scripts doesn't work anymore that would lump all characters into a single folder.

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        workspace.chars:WaitForChild()

        char.Parent = workspace.chars
    end)
end)

This script used to run just fine but now, for some reason, it won't let me move a character until I add something like a 3 second wait.

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        workspace:WaitForChild("chars")
        print("Loaded")

        char.Parent = workspace.chars
    end)
end)

I even changed the WaitForChild to how it now works and "Loaded" does, in fact, print. And adding in a print(char) beforehand does register that there is a character before the parent is supposed to be changed. But for some reason the game outright refuses to put the character in the folder like it's supposed to. What am I missing? Is there something about when you can set the character's parent now?

Answer this question