i’m back . . .
this script is only sometimes working in my NEW game, i’ve used the same script (slightly changed) in other games and it’s worked perfectly fine, but in this game, sometimes the player loads with the nametags, and sometimes not.
It is important to note that I have game.Players.CharacterAutoLoads = false, and a manual :LoadCharacter() system.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local clone1 = game.ReplicatedStorage.Overhead1:Clone()
local clone2 = game.ReplicatedStorage.Overhead2:Clone()
local clone3 = game.ReplicatedStorage.Overhead3:Clone()
clone1.Parent = character.Head
clone1.Adornee = character.Head
clone2.Parent = character.Head
clone2.Adornee = character.Head
clone3.Parent = character.Head
clone3.Adornee = character.Head
if player.Name == "ollieryz" then
clone3.Enabled = true
clone3.TextLabel.Text = "CREATOR"
end
if player.Name == "jackeryzTTV" then
clone3.Enabled = true
clone3.TextLabel.Text = "CONTENT CREATOR"
clone3.TextLabel.TextColor3 = Color3.fromRGB(196, 42, 37)
end
clone2.TextLabel.Text = player.Name
clone1.TextLabel.Text = "beginner"
end)
end)
This is probably happening because your scripts are just executing at different times. Your LoadCharacter system might be taking too much of your computer’s resources on join, which causes your player to join before the nametag script has connected its own function to game.Players.PlayerAdded.
Servers (in-game) are given a lot of time (maybe 5 seconds) before the first player joins a new server, which means this shouldn’t cause a problem in a real game.
I just tested this in one of my games:
in studio, the server had roughly 1/6 of a second before my player joined
in-game, the server had roughly 3 seconds before my player joined
In conclusion and based on the evidence you presented, I don’t think you will have to worry about this, as it seems like an “only in studio, not in-game” bug.
If you still don't want this to happen for the sake of consistency:
You can guarantee that this doesn’t happen by requiring this script as a module under the same one that utilizes your manual :LoadCharacter() system:
--for the script you presented:
local NameTagLoader = {}
function NameTagLoader:LoadNameTag(character) --kind of redundant lol
--everything in the player.CharacterAdded function
end
return NameTagLoader
--in the :LoadCharacter system
local NameTagLoader
game.Players.PlayerAdded:Connect(function(player)
if not module then
module = require(script.NameTagLoader)
end
--...
player:LoadCharacter()
do
local character = player.Character or player.CharacterAdded:Wait()
module:LoadNameTag(character)
--...
end
end)
NameTagLoader = require(script.NameTagLoader) -- as an example
I don’t really have any other reason to believe this is happening unless you put some kind of silly wait in your scripts somewhere before connecting your events…
For nametags, its easier to have a script in StarterCharacterScripts than connecting a PlayerAdded and CharacterAdded events.
Also, moving it to StarterCharacterScripts should remove inconsistency.