Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Adaptive music script dosent stop after death?

Asked by 1 year ago

So i have this script that plays the low health music when you get damaged, But for some reason if you regenerate health the music stops and plays the normal music but if you die the low health music dosent stop,

i also want to add music that plays after your death for 4 seconds then switch to normal music if you can do that

LocalScript:


local player = game.Players.LocalPlayer local char = player.CharacterAdded:Wait() local cam = game.Workspace.CurrentCamera while wait(0.2) do if char.Humanoid.Health <= 40 then game.Workspace.LowHealth.Playing = true game.Workspace.NormalHealth.Playing = false wait(4) else game.Lighting.ColorCorrection.Contrast = 0.2 game.Workspace.LowHealth.Playing = false game.Workspace.NormalHealth.Playing = true cam.FieldOfView = 100 end end player.CharacterAdded:Connect(function(character) char = character end)

1 answer

Log in to vote
0
Answered by 1 year ago

When the character is added you have to reset the music and every thing you have I could not test this out so I hope it works

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local cam = game.Workspace.CurrentCamera

while wait(0.2) do
    if char.Humanoid.Health <= 40 then
        game.Workspace.LowHealth.Playing = true
        game.Workspace.NormalHealth.Playing = false
        wait(4)
    else
        game.Lighting.ColorCorrection.Contrast = 0.2
        game.Workspace.LowHealth.Playing = false
        game.Workspace.NormalHealth.Playing = true
        cam.FieldOfView = 100
    end
end
player.CharacterAdded:Connect(function(character)
    char = character
    game.Lighting.ColorCorrection.Contrast = 0.2
    game.Workspace.LowHealth.Playing = false
    game.Workspace.NormalHealth.Playing = true
    cam.FieldOfView = 100
end)
Ad

Answer this question