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)
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)
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.