Need help on my scripters script

So my for the most part newer scripter needs help on coding our Combat Music script. It’s suppose to check for when the player takes damage, play combat music (Would fade in), and after 5.5 seconds, it would end (Fade out).

  1. What do you want to achieve?
    I want to achieve a script that can basically play music when you take damage
  2. What is the issue? Include screenshots / videos if possible!
    Not sure, but the script from what we know of just wont play the music, I’ve changed it to be put inside SoundService, still didn’t work, put in Workspace, still didn’t work, and finally what we put it back in ReplicatedStorage, STILL didn’t work.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Haven’t checked the Dev Hub but we’ve tried placing it in different areas of the engine (replicatedstorage, soundservice, workspace, in and out of a folder also)
    Script and wheres its located here -


Other than that uh yeah, we just need some help on it! :smiley:

Oh boy.

  1. You can just get the elapsed time since the Event happened using tick() or time().

  2. you should be using TweenService or a loop, instead of waiting every .1 seconds for it to change.

Because LocalScripts cannot run in those environments, if you didnt read where they could run.

1 Like

The problem is that, since you’re using the same health variable, your health is not going to be less than your health, and they will always be the same value.

local damagemusic = game.ReplicatedStorage.Sounds["Combat Music"]

		local combatvalue ="BoolValue",char)
		local oldhealth = char.Humanoid.Health -- Health before HealthChanged runs
			if health < oldhealth then -- Checks if new health is lower
				-- Put code here
			oldhealth = health -- New value for health to check if it is greater or lower

Also I’d suggest instead of using many wait()s, you can use a Tween or for i = 1,10 loop.

1 Like

Sorry for a late reply, I notified my scripter and yeah he thanks you, I can read code and I asked him about it, and he said it should work, but yeah after reading this it fixed the problem. Thanks :smiley:

And thank you for that, also told him about that

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.