It has always(?) been the case that the player in Play Solo was called Player1, but I noticed today that that had changed to be my actual username ‘MasterDaniel’.
However, whilst game.Players shows ‘MasterDaniel’ as a player, my character in workspace is called ‘Player1’, breaking many parts of my game when I’m testing in studio.
Its something to do with either CharacterAutoLoads or LoadCharacter
Its solved by adding a wait() after PlayerAdded.
This code can be used to reproduce the bug
local Players = game:GetService("Players")
Players.CharacterAutoLoads = false
Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:connect(function()
Player:LoadCharacter()
end)
end
end)
Player:LoadCharacter()
end)
EDIT 27/08
So this was supposedly fixed, but the following code, originally posted in #10 still results in the error. Its nothing to do with LoadCharacter as I first thought.
Nope, nope and nope. Although it is also happening in a previous version of the game (I originally observed this issue on my test server) which has not been changed at all and it was previously 100% working.
I’ve checked my other games and they seem to be working ok. Very odd. Not sure whether this is my bug or not now
Looks like some of my code has gone rogue. When I delete all code from my game the problem doesn’t present itself.
Whats interesting though is what I said before: This bug affects the other version of my game but never used to (and I haven’t changed it since it worked).
I’ll start re-adding code to see what breaks it (I have a hunch)
OK I’ve found the bug. Its in a script that deals with “CharacterAutoLoads” and “LoadCharacter” which may, or may not be the problem.
I’m not sure how this code is resulting in the observed bug.
local Players = game:GetService("Players")
Players.CharacterAutoLoads = false
Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:connect(function()
Player:LoadCharacter()
end)
end
end)
Player:LoadCharacter()
end)
Was able to reproduce with that code (after removing the require) in a new place: after the character resets everything is fine, but the first time I spawn in my character is named Player1 and its appearance doesn’t load either, so I wonder if it’s something along the lines of LoadCharacter not being entirely ready when you call it so soon. @Osyris was working with LoadCharacter for R15 purposes recently, so he may be familiar with it enough to shed insight on what’s happening.
Printing that prints “Player1” for me.
Without that script, my character in the workspace is called “MasterDaniel”.
When that script is added, my character is called “Player1”