I’ve been using LoadCharacter() to load characters containing humanoids inside my game. I’ve realized that I dont have any wait(), WaitForChild(), or something like that in my scripts. I’ve never used LoadCharacter() much in my scripting daily basis. Is it supposed to be like that?
How long approximately? It may be because an avatar has a lot of assets to load
Its taking approximately around 15 seconds, my avatar is quite simple has only around 3 accessories.
It doesn’t matter truthfully if you have any waits or anything, at the end of the day your at the mercy of the engines capabilities and all the scripts.
So its because of the game performance? Cause sometimes its fast and sometimes its not?
If you give me a moment I can see how much time it takes on my end (benchmark
Have you tried using player.CharacterAdded:Wait() or player.Character
note I have not referenced the player so you would need to do so.
I already have disabled CharacterAutoLoads from Players Service and I made my own respawning and loading system. But when I respawn my character the respawning is sometimes fast, and sometimes not. Here’s my script part.
local function LoadCharacter(player, charactername)
player:LoadCharacter()
local UfoFolder = game.ReplicatedStorage.UFOs
local NewCharacter = UfoFolder:FindFirstChild(charactername):Clone()
NewCharacter.Parent = workspace
NewCharacter.Name = player.Name
player.Character = NewCharacter
NewCharacter:MoveTo(workspace.MainSpawn.Position + Vector3.new(0, 10, 0))
local CameraFixer = script.Camera:Clone()
CameraFixer.Disabled = false
CameraFixer.Parent = player:WaitForChild("PlayerGui")
local Remote = game.ReplicatedStorage.Remotes.LoadedUfo
Remote:FireClient(player, NewCharacter)
NewCharacter.Humanoid.Died:Connect(function()
LoadCharacter(player, EquippedUfo.Value)
end)
end
If its in studio playtesting and its slow its probably your internet since it needs to contact roblox servers to get your avatar to your pc
As you can see its labelled as a yielding function (which is basically just waiting)
Oh alright! I’m gonna try my game inside normal roblox servers and let you know if it fixed my problem. Thanks.
I couldn’t get valid results because LoadCharacter is async but it didn’t take 15 seconds? I think it has to do with your spawning script
It still hasn’t fixed my problem I have a custom character in my game. And its still doing the same problem?
Also to that script I would suggest doing
NewCharacter.Humanoid.Died:Wait()
LoadCharacter(player, EquippedUfo.Value)
instead so the .Died doesn’t fire more than once
LoadCharacter()
may have been replaced by .CharacterAdded:Wait()
that might be the reason your load was slow
LoadCharacter spawns in the character
CharacterAdded:Wait() waits until it spawns
it hasnt been replaced
Here’s a video it took around 15 secs for it to respawn me again? Edit: Actually close to 25
Can you do a print debug to make sure its the :LoadCharacter()
causing the delay?
or if its something else in the script
memory Leak you are making new connections every time you load character
Can you load a fresh instance of the game and try respawn? Is it the same time?
Wait why do you need to load your character everytime?
Because you load the character and then switch it to the NewCharacter, can’t you just remove the player:LoadCharacter()
or am I wrong here?