LoadCharacter gives errors FREQUENTLY!

Calling our function fragile when nobody can reproduce this supposed issue doesn’t exactly add up. The loadcharacter method gets called every time a player joins a game on roblox. It’s also called whenever they respawn. This happens millions of times per day. It might be an understatement to say it’s some of the best working code in the ROBLOX engine.

That doesn’t mean there can’t be bugs, but I need to know how you’re causing these errors before I can fix it.[/quote]

Feel free to lock the thread. I’v been through the code multiple times and can’t find anything unusual that would cause it. I can’t disassemble 500k lines of code to find the source. I don’t have the time, given the recent xbox deadlines aswell as my own game deadlines + college.

It would’ve helped if I could get the context of roblox scripts that prints this error. That way I’d understand abit more what I were to look for. I always save in multiple version (Note to self: 2.6.7) so incase you can supply me with given context I’ll give an extra shoot at finding the source once I get some time off.

The only time that error gets called is if the primary part of a model isn’t set.

CoordinateFrame ModelInstance::getPrimaryCFrame()
{
	if (PartInstance* primaryPart = getPrimaryPart())
	{
		return primaryPart->getCoordinateFrame();
	}
	
	throw std::runtime_error("Model:GetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.");
}

Ok then I can’t help you. I never use the function “getPrimaryCFrame” in any of my codes :confused:
But it’s no biggie, since I’m the only one getting it and i’v already worked around.

Is there possibly code somewhere in the C++ side of spawning characters that uses getPrimaryCFrame?

Setting a primary part CFrame does use getPrimaryCFrame to determine the old cframe.

The issue here is that PlaceRebuilder is doing something that forces this to be unset, or never initially set (perhaps a call that doesn’t wait for the character to load in). We really need to know what he’s doing to figure it out.

Possibly, he is not waiting for the character to spawn before calling SetPrimaryPartCFrame? This would most likely cause that issue and is my best guess as to what he’s doing wrong.

A fix to this is to use the CharacterAdded event or a waitforchild.

[quote] Setting a primary part CFrame does use getPrimaryCFrame to determine the old cframe.

The issue here is that PlaceRebuilder is doing something that forces this to be unset, or never initially set (perhaps a call that doesn’t wait for the character to load in). We really need to know what he’s doing to figure it out.

Possibly, he is not waiting for the character to spawn before calling SetPrimaryPartCFrame? This would most likely cause that issue and is my best guess as to what he’s doing wrong.

A fix to this is to use the CharacterAdded event or a waitforchild. [/quote]

Sounds plausible!
My code is like this:

player:LoadCharacter()
local torso = player.Character:WaitForChild("Torso")
torso.CFrame = CFrame.new(0,1000,0)

That is your new code correct?

Was the old code doing something along the lines of

player:LoadCharacter()
player:SetPrimaryPartCFrame(...)

?

That would work in play solo because of the environment, POSSIBLY work in a test server, but would not work in an environment with any latency.

[quote] That is your new code correct?

Was the old code doing something along the lines of

player:LoadCharacter()
player:SetPrimaryPartCFrame(...)

?

That would work in play solo because of the environment, POSSIBLY work in a test server, but would not work in an environment with any latency. [/quote]

I’v never used the SetPrimaryPartCFrame before. The code I showed has been in use for a long time.
Perhaps there might been other operations inbetween the loadcharacter and torso.CFrame that would given the game some time to calculate an initial cframe?

Eitherway this is how I’v spawned players for ages now, it’s still working in current R2D which is nothing short of black magic.

The only place this is used would be inside of the SpawnLocation code. Other than that, we actually don’t use this method internally. So that would be the culprit.

Does your game create/destroy spawnlocations around the same time you’re calling LoadCharacter?

[quote] The only place this is used would be inside of the SpawnLocation code. Other than that, we actually don’t use this method internally. So that would be the culprit.

Does your game create/destroy spawnlocations around the same time you’re calling LoadCharacter? [/quote]

My game contains no spawnplates at all. I teleport the players to ordinary parts instead.
THAT! However, is the difference between Xbox and PC version of R2D.
In PC version I got two spawnplates, one for each team. They are permanent, they do not move nor gets removed. In XBox version I don’t even have them.

You might be onto something here!