Sound (Instance) doesn't stop

  1. What do you want to achieve? I wanna stop the sound if info.wave value is 40 (number value)

  2. What is the issue? It keeps playing even if info wave value is 40

  3. What solutions have you tried so far? None

local infoWave = workspace.Info:FindFirstChild("Wave")
local TDesert ="Sound")

TDesert.Name = "The Desert"
TDesert.SoundId = " not going to show the id"
TDesert.Volume = 1.5
TDesert.Looped = true
TDesert.archivable = true

TDesert.Parent = script.Parent


if infoWave.Value == 40 then

(also tell me if this is wrong category)

Because the conditional statement was not included in a loop, function, etc., the script is only checking if its Value is equal to 40 one time (when it starts running that part of the script).

This means that if the Value ever reaches 40 after the condition was checked for, it would not stop the sound because the script was only instructed to compare infoWave.Value to the number 40 one time, immediately after the sound starts playing.

To ensure that it will keep track of its Value when it changes, you can use :GetPropertyChangedSignal("Value") on infoWave and then connect that to a function. It will run that function every time the Value property of infoWave changes, which is where the conditional statement can be placed to check if the new Value has reached the threshold of 40.

Example Revision


    if infoWave.Value >= 40 and TDesert.IsPlaying == true then
1 Like

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