My StarterPlayer Nextbot isn't working

Hello all!
I was trying to make a nextbot game that is your avatar and I ran into a problem. I’m trying to assign the nextbot as the starerplayer but that won’t work for me.

Code:

function CreatePlayerNextbot(player: Player, char: Model)
	local Nextbot = script.StarterCharacter
	local retries = 0
	local success
	local avatarImage
	local isReady
	repeat
		retries = retries + 1
		success, avatarImage, isReady = pcall(function()
			return game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		end)
	until success and isReady or retries == 3
	if success then
		Nextbot.HumanoidRootPart.BackTexture.Texture = avatarImage
		Nextbot.HumanoidRootPart.FrontTexture.Texture = avatarImage

	else
		Nextbot.HumanoidRootPart.BackTexture.Texture = script.obunga.Texture
		Nextbot.HumanoidRootPart.FrontTexture.Texture = script.obunga.Texture
	end
	Nextbot.Parent = game:GetService("StarterPlayer")
	char = Nextbot
end	

game.Players.PlayerAdded:Connect(function(Player)
	local Char = Player.Character or Player.CharacterAdded:Wait()
	CreatePlayerNextbot(Player, Char)
end)

Setup:
Screen Shot 2022-09-28 at 7.36.46 PM

Thanks
@Tomroblox54321

You have to change the actual character property of the player.

New code:

local function CreatePlayerNextbot(player: Player)
	local Nextbot = script.StarterCharacter
	local retries = 0
	local success
	local avatarImage
	local isReady
	
	repeat
		retries = retries + 1
		success, avatarImage, isReady = pcall(function()
			return game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		end)
	until success and isReady or retries == 3
	
	if success then
		Nextbot.HumanoidRootPart.BackTexture.Texture = avatarImage
		Nextbot.HumanoidRootPart.FrontTexture.Texture = avatarImage
	else
		Nextbot.HumanoidRootPart.BackTexture.Texture = script.obunga.Texture
		Nextbot.HumanoidRootPart.FrontTexture.Texture = script.obunga.Texture
	end
	
	Nextbot.Parent = game:GetService("StarterPlayer")
	player.Character = Nextbot
end	

game.Players.PlayerAdded:Connect(function(Player)
	if not Player.Character then
		Player.CharacterAdded:Wait()
	end
	
	CreatePlayerNextbot(Player)
end)
1 Like

Thanks so much it worked. But when I join my character is invisible for a second or 2. Do you know to fix that?

That’s probably just a decal loading problem. You can try placing the Nextbot in ReplicatedStorage so it can load immediately in the client and changing the code a bit.

1 Like

I believe it is a problem like that. I guess I’ll put it in it’s own lobby for a couple of seconds and then put it out. Thanks a ton!

1 Like

No problem. If you have any more questions, feel free to ask.

1 Like