Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

:LoadCharacter() not functioning properly?

game.Player.PlayerAdded:connect(function(player)
	player:LoadCharacter()
	print("1")
		
	player.CharacterAdded:connect(function(character)
		print("2")
		character.Parent = workspace:WaitForChild("PlayerHolder")
	end)
end)

It prints 1 in the output, but doesn't print 2. Why is this? I have CharacterAutoLoads turned to false

Basically what I'm trying to do is keep all the players inside a folder in workspace, PlayerHolder so I get to their characters easier.

2 answers

The reason why the function isn't working is because you don't set up the event when you first Load the character.

You have to set up the event and function before calling the LoadCharacter function in order for it to fire.

game.Player.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		print("2")
		character.Parent = workspace:WaitForChild("PlayerHolder")
	end)

	print("1")
	player:LoadCharacter()
end)

1 comment

0

This.

It's because, you can't load the character before it has been added

game.Player.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        player:LoadCharacter()
	print("2")
        character.Parent = workspace:WaitForChild("PlayerHolder")
    end)
end)

So basically, loadcharacter just refreshs/ respawns the character. It doesn't "load" it, in terms of what you were thinking of.

2 comments

0

I don't think so

2

This wouldn't work. It'd just make an infinite loop of re-loading the character when it's loaded once.

This discussion is preserved as it was. New answers, comments, and votes are closed.