CharacterAdded only firing when the character 'respawns' instead of 'spawning'?
The issue is, when the player's character spawns (when the player first joins the game), the code I wrapped inside of CharacterAdded won't run at all. But when my player's character respawns, everything runs just fine.
I don't think it's because the player joined before the server initializes, because I used one of my alt accounts on a different device to join an already opened server, and the results are the same.
I also don't think it's because of the code inside of CharacterAdded, I even tried
1 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
2 | plr.CharacterAdded:Connect( function (char) |
and it still doesn't print 'works'.
If anyone thinks of what the issue is, please help me out.
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
02 | plr.CharacterAdded:Connect( function (char) |
03 | local head = char:WaitForChild( "Head" ) |
04 | local hum = char:WaitForChild( "Humanoid" ) |
05 | local BW = hum:WaitForChild( "BodyWidthScale" ) |
06 | local BH = hum:WaitForChild( "BodyHeightScale" ) |
07 | local BD = hum:WaitForChild( "BodyDepthScale" ) |
08 | local tor = char:WaitForChild( "UpperTorso" ) |
09 | local lhand = char:WaitForChild( "LeftHand" ) |
10 | local rhand = char:WaitForChild( "RightHand" ) |
11 | local lhandswing = Instance.new( "Sound" , lhand) |
13 | lhandswing.Name = "LeftHandSwing" |
15 | local rhandswing = Instance.new( "Sound" , rhand) |
17 | rhandswing.Name = "RightHandSwing" |
20 | hum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None |
21 | hum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff |
23 | hum.MaxHealth = hp.Value |
26 | hp.Changed:Connect( function () |
27 | hum.MaxHealth = hp.Value |
31 | local randomBW = math.random( 5 , 30 ) |
32 | randomBW = randomBW / 10 |
33 | BW.Value = BWSave:GetAsync(k) or randomBW |
34 | BWSave:SetAsync(k, BW.Value) |
36 | local randomBH = math.random( 5 , 30 ) |
37 | randomBH = randomBH / 10 |
38 | BH.Value = BHSave:GetAsync(k) or randomBH |
39 | BHSave:SetAsync(k, BH.Value) |
41 | BD.Value = BWSave:GetAsync(k) or randomBW |
43 | BW.Changed:Connect( function () |
45 | BWSave:SetAsync(k, BW.Value) |
48 | BH.Changed:Connect( function () |
49 | BHSave:SetAsync(k, BH.Value) |