Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Adaptive music script dosent stop after death?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.