My current script that does not work
1 | repeat wait() until game:GetService( "Players" ).LocalPlayer |
2 | local Character = workspace:FindFirstChild(game.Players.LocalPlayer.Name) |
3 | while wait() do |
4 | if Character:FindFirstChild( "Humanoid" ) then |
5 | if Character.Humanoid.Health.Value < = 0 then |
6 | game.Workspace.Medium.MusicCrazy:Stop() |
7 | end |
8 | end |
9 | end |
Just use the died event instead
1 | game:GetService( 'Players' ).PlayerAdded:Connect( function (player) |
2 | player.CharacterAdded:Connect( function (character) |
3 | character:WaitForChild( "Humanoid" ).Died:Connect( function () |
4 | game.Workspace.Medium.MusicCrazy:Stop() |
5 | end ) |
6 | end ) |
7 | end ) |