LoadCharacter gives errors FREQUENTLY!

I’v been using player:LoadCharacter() for as long as I can remember. Never had an issue with it.

Now upon the coming release of XBox I’v been getting this error:

Model:GetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

It doesnt even make sense! How can I set primary part on a model that doesn’t exist yet?!
It breaks my game from the foundation. I cant respawn the player and the gamecore breaks cause it cant load a new round of players.

Here’s the scripts.
The error is in GameCore, line 171.

This issue is urgent! :frowning:

I take it you’re trying to get the PrimaryPartCFrame of the Character after you use LoadCharacter()?

I quickly scripted this to test it in Studio, and it printed perfectly.

game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) print(Character:GetPrimaryPartCFrame()) end) wait(1) Player:LoadCharacter() end)

I tried it both with CharacterAutoLoads set to true, and to false. It worked both times.

1 Like

Thanks!
But I’m not trying to get PrimaryPartCFrame anywhere in my code. That error message is bs.
I just want to spawn player by doing loadcharacter.

Repro file please – just like AlgyLacey, I’m not having this issue when using LoadCharacter, so it’s probably some other script of yours interfering. It’s impossible to help you if you don’t include a repro file.

Can you make a repro file and attach it? I can look into it if you do that, but I couldn’t reproduce it myself.

Added the scripts.
I didn’t think anyone would care to look through the code, it’s abit of a mess…

Please attach a place file and not model files – those scripts rely on your game architecture to run (i.e. there’s no RStorage under game in our places (and please tell me that’s a custom model/folder and you’re not renaming ReplicatedStorage to RStorage)), so it’s impossible for us to reproduce the bug with just these scripts. Repro files allow us to reproduce the issue – loose scripts that you throw out to us “here find the problem” don’t help us do that.

Also, the simpler the repro file the better.

Not only does this make it easier for the staff to figure out what’s causing the bug, but in the case that it’s something wrong with your code, when you narrow it down to bare-bones you’ll end up finding the exact problem.

Ah, gots it!
I’ll try see if I can replicate the error somehow.

Safe to assume this was an issue with your game and not LoadCharacter?

Still haven’t found what’s causing this bug.
I am not doing anything wierd. Im not trying to spawn a player 10 times or spawning, removing, spawning, removing.
I’m doing none of that.

Can I get the relevant/surrounding sourcecode that returns this error?
I’m shooting in the dark right now, have no idea what to look for…

If you’re having trouble narrowing down the problem you’re doing it wrong. Start removing unecessary items that couldn’t be possibly causing the bug (i.e. unrelated scripts and random functions inside of the original script) until there’s nothing left but what causes the issue. This time though, just upload the entire place and I’ll find out what the issue is.

Idk if you ever had a big game before but you can’t just remove parts and have everything still working.
You can’t disassemble one part without having to remove the next part and the next part until you’re left with nothing, which wont produce anything. There’s no real smooth decomposition.

I can confirm, everything works FINE until I try to spawn all players characters using LoadCharacter.
For some reason I get this error and then the players character still hasn’t spawned.

[quote] Idk if you ever had a big game before but you can’t just remove parts and have everything still working.
You can’t disassemble one part without having to remove the next part and the next part until you’re left with nothing, which wont produce anything. There’s no real smooth decomposition.

I can confirm, everything works FINE until I try to spawn all players characters using LoadCharacter.
For some reason I get this error and then the players character still hasn’t spawned. [/quote]

You’re not the only one who’s reported bugs before. More than a few times before I have discovered a bug while working on a game (that’s probably how I find most bugs actually) and dumbed it down to one script for the repro file. I even did it with one of Stravant’s plugins and found that the issue was activating plugins period (which has since been fixed, likely because I narrowed down and found the exact issue instead of saying “Oh here’s a total of 20,000 lines of code find the issue for me!”) You sound like you’re giving up even before trying, and that’s exactly why I offered to do it for you.

[quote] Idk if you ever had a big game before but you can’t just remove parts and have everything still working.
You can’t disassemble one part without having to remove the next part and the next part until you’re left with nothing, which wont produce anything. There’s no real smooth decomposition.

I can confirm, everything works FINE until I try to spawn all players characters using LoadCharacter.
For some reason I get this error and then the players character still hasn’t spawned. [/quote]

You’re not the only one who’s reported bugs before. More than a few times before I have discovered a bug while working on a game (that’s probably how I find most bugs actually) and dumbed it down to one script for the repro file. I even did it with one of Stravant’s plugins and found that the issue was activating plugins period (which has since been fixed, likely because I narrowed down and found the exact issue instead of saying “Oh here’s a total of 20,000 lines of code find the issue for me!”) You sound like you’re giving up even before trying, and that’s exactly why I offered to do it for you.[/quote]

Oh, didn’t see that.
Thanks man, that’s really kind of you!
But I think i’ll just redo the whole way I load characters. Since LoadCharacter() is a roblox function, returning an error when called, I’ll make my own loadcharacter without roblox fragile functions.
That way, even if I get an error, the error is going to be an error that gives relevant information concerning the source of the issue.

You have a duty to report the bug to the best of your ability so that even if it doesn’t help you immediately others won’t run into it in the future. Again, if you can’t find the motivation to do that, I will be more than happy to find the exact cause for you, but one way or another this bug needs to be addressed.

Stop trying to get my game, you’re not gonna get it.

Uh… I’m not trying to get your game. I’m trying to get you to properly confirm and report or debunk this bug. The only reason I offered to do it for you is because you seem hell-bent on not doing it yourself because it’s “too much work” and you don’t care about people who may experience the same bug in the future even slightly. I wouldn’t be a member of the developer forums if I was the type of person to steal other peoples’ games. And no offense, but there would be no situation I could find myself in where I would want your place file in the case I wanted to make a similar game, because I would rather build it properly and the bare-bones code your games run off is not something I would want for my game.

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.