ReplicatedStorage Clone Glitch

I have script that clones and displays certain characters from replicated storage. The issue is when you first call the models using ReplicatedStorage.Character:Clone() and put it in the workspace it displays this weird glitch. Subsequent attempts to call the character however will not display this despite being entirely new models as well because whenever you switch characters it destroys the previous one.

for i,v in pairs(script.Parent.CharacterSelect.Characters:GetChildren()) do
	local TextButton = v.TextButton
	
	TextButton.MouseButton1Click:Connect(function()
		if workspace.DisplayCharacter:FindFirstChild("Character") then
			workspace.DisplayCharacter:FindFirstChild("Character"):Destroy()
		end
		
		local Character = Replicated[v.Name.."Character"]:Clone()
		Character.Name = "Character"
		Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.Model.CameraPart.CFrame * CFrame.new(0,0,-10) * CFrame.Angles(0,math.rad(180),0)
		Character.Parent = workspace.DisplayCharacter
		CharacterSelected = v.Name
			
	end)
end

This is because the appearance of the character isn’t loaded until its been rendered on the screen. After its been loaded once, it will remain loaded, which is why you’re seeing the happen only the first time.

To prevent this, you can preload the assets so they can be shown immediately.

local ContentProvider = game:GetService("ContentProvider")
local Replicated = -- where your characters are located

ContentProvider:PreloadAsync({Replicated})

To add onto what Gnarwhal said, dont destroy it till the menu is closed, cache it to avoid that extra loading time

local ContentProvider = game:GetService("ContentProvider")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Assets = ReplicatedStorage:WaitForChild("Characters")

ContentProvider:PreloadAsync({Assets})

Not sure if I did this right, the problem is still persisting. I put this in a new local script in replicated first.

Based off what you have stated.
A server script in ServerScriptService

task.wait(1)

local Replicated = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")

local characterNames = {}
for _, v in pairs(script.Parent.CharacterSelect.Characters:GetChildren()) do
    table.insert(characterNames, v.Name.."Character")
end

local charactersToPreload = {}
for _, characterName in ipairs(characterNames) do
    table.insert(charactersToPreload, Replicated:WaitForChild(characterName))
end

ContentProvider:PreloadAsync(charactersToPreload)

Should cover all your preloaded needs with the Characters.

  1. The CharacterSelect is a local gui so it wouldnt work on the server.
  2. I replicated it by just doing
task.wait(1)

local Replicated = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")

local charactersToPreload = {}
for i,v in pairs(Replicated:WaitForChild("Characters"):GetChildren()) do
	table.insert(charactersToPreload, v)
end
print(charactersToPreload)
ContentProvider:PreloadAsync(charactersToPreload)

And the issue still persisted, also wouldn’t I want to preload the instances on the client instead of the server, if a player joins after the server runs the script then would the client have the unloaded instances?

I tired to get all your Character names in this part .. you may want to print check that to make sure it’s getting them right.

The one I use is from server-side but, you can still do this in a client script in StarterPlayerScripts

“if a player joins after the server runs the script then would the client have the unloaded instances?” … in StarterPlayerScripts should cover that also. It would be buffering per player at that point.

One I'm using
task.wait(1)
local cars=game:GetService("ServerStorage"):WaitForChild("CarFolder")

local preload={}
local content={"Coupe01","Chevy01",
	"IronHead","Super01","Hellcat01"
}
local ContentFolder=game:GetService("ServerStorage"):WaitForChild("CarFolder")
local ContentProvider=game:GetService("ContentProvider")
for _,objName in ipairs(content) do
	table.insert(preload,ContentFolder:WaitForChild(objName))
end ContentProvider:PreloadAsync(preload)

I used to just spawn everything in under the baseplate then delete it after a bit untill I found out about how this works. That works also …

I have used the methods by everyone here so far and none of the preloaded functions are working as intented it seems. Im starting to think that somethings isnt enabled or something.

Also If I copy the character models from replicated storage and put them in the workspace, the character load just fine using the script.