I have this script (pseudo) that runs after player joins and datastore has fully loaded:
function LoadCharacter(player)
-- added
player.CharacterAdded:connect(function(character)
-- add weapon
local weapon = Weapons[weapon]:Clone()
weapon.Name = "Weapon"
weapon.Parent = character
spawn(function()
local start = tick()
while wait() and (tick() - start) < 4 do
local w = character:FindFirstChild("Weapon")
if not w then
local msg = Instance.new("Hint",workspace)
msg.Text = "Weapon not loaded: " .. data.inventory.weapons[using][1] .. "_" .. tick() - start
break
end
end
end)
end)
player:LoadCharacter()
end
For some reason, when the players first joins, they sometimes (3 out of ~4000 sessions) have no weapon. According to my “hint” section, the weapon does get parented, but it disappears after ~1.5-3.0 seconds. My theory was that its a bug where the weld sometimes doesn’t get created since it happens so rarely. But I’ve searched and no one seems to have this problem (as of late) and manually creating the weld didn’t solve it either.
So I decided to post here, wondering if me parenting the tool like this is bad practice? Maybe the character hasn’t fully loaded on “CharacterAdded” and it “resets” the children after I parent? Or something. I don’t know what to do apart from creating a loop that reparents the weapon whenever it disappears …