When a new player joins my game, I want their character in the Workspace to be moved to a folder named “Characters”. Here is a photo of the hierarchy:
To do this, I wrote a script in the server as shown:
-- services local Workspace = game:GetService("Workspace") local Players = game:GetService("Players") -- variables local characters = Workspace:WaitForChild("Characters") -- player join Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) while not character.Parent do character.AncestryChanged:wait() end character.Parent = characters end end
However, when I test it, this is the outcome:
My character is obviously not parented to the “Characters” folder. And here is the error thrown by the script:
Why is this happening and how do I fix it?