How to change player character parent

Hello! So I want it that player character parent was a “Alive” folder inside workspace. However I don’t know do it. I have tried this:

game.Players.PlayerAdded:Connect(function(plr)
  plr.CharacterAdded:Connect(function(char)
  char.Archivable = true
  char.Parent = workspace.Alive
  end)
end)

It didn’t work. Character model still inside workspace.
Any help appreciated!

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(char)
		char.Archivable = true
		char.Parent = workspace.Alive
	end)
end)

https://developer.roblox.com/en-us/api-reference/event/Player/CharacterAppearanceLoaded

Nothing happened. Character model still inside workspace.

That’s weird because it worked for me, one moment.

You made sure to do this in a server script right?

Yeah. I will send the full script code:

local main = require(game.ServerStorage.Modules.MainModule)

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder",player)
	stats.Name = "Stats"
	local cards = Instance.new("Folder",stats)
	cards.Name = "Cards"
	
	local equippedCards = Instance.new("Folder",stats)
	equippedCards.Name = "EquippedCards"
	
	local b = main.CreateBool("Beam")
	b.Parent = cards
	local b1 = main.CreateBool("Zone")
	b1.Parent = cards
	
	for i = 1,4,1 do
		local equipped = Instance.new("StringValue",equippedCards)
		equipped.Name = "Card"..i
		equipped.Value = "Zone"
	end
	
	player.CharacterAppearanceLoaded:Connect(function(char)
		char.Archivable = true
		char.Parent = workspace.Alive
	end)
end)

game.ReplicatedStorage.Events.EquipCard.OnServerEvent:Connect(function(player,cardname,slotindex)
	local cards = player.Stats.Cards
	local equippedCards = player.Stats.EquippedCards
	
	if cards:FindFirstChild(cardname) then
		local slot = equippedCards:FindFirstChild("Card"..slotindex)
		
		if slot.Value == cardname then
			slot.Value = "None"
			return
		end
		
		for _,slotv in pairs(equippedCards:GetChildren()) do
			if slotv.Value == cardname then
				slotv.Value = "None"
			end
		end
		
		slot.Value = cardname
	else
		player:Kick("Choosen card wasn't found inside your inventory. Most likely exploit. Please contact developer if you think this is wrong.")
	end
end)
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)
		char.Archivable = true
		char.Parent = workspace.Alive
	end)
	local stats = Instance.new("Folder",player)
	stats.Name = "Stats"
	local cards = Instance.new("Folder",stats)
	cards.Name = "Cards"

	local equippedCards = Instance.new("Folder",stats)
	equippedCards.Name = "EquippedCards"

	local b = main.CreateBool("Beam")
	b.Parent = cards
	local b1 = main.CreateBool("Zone")
	b1.Parent = cards

	for i = 1,4,1 do
		local equipped = Instance.new("StringValue",equippedCards)
		equipped.Name = "Card"..i
		equipped.Value = "Zone"
	end
end)

Nothing happened. Character still inside workspace.

You may just need to add an arbitrary wait like “task.wait(3)” etc.

repro.rbxm (938 Bytes)

Here’s a model file which worked for me. The folder goes inside the workspace and the script goes inside the “ServerScriptService” folder, nothing needs to be renamed.

Proof it works:

image

2 Likes

hello, simply try adding wait(1)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(char)
                wait(1)
		char.Archivable = true
		char.Parent = workspace.Alive
	end)
end)

here’s explanation why it didn’t work: Avatar Loading Event Ordering Improvements

1 Like

Thank you! It’s now changes player character parent!

Thank you! It changes player character parent!

1 Like