What do you want to achieve? I wanna stop the sound if info.wave value is 40 (number value)
What is the issue? It keeps playing even if info wave value is 40
What solutions have you tried so far? None
local infoWave = workspace.Info:FindFirstChild("Wave")
local TDesert = Instance.new("Sound")
TDesert.Name = "The Desert"
TDesert.SoundId = "http://www.roblox.com/asset?id= not going to show the id"
TDesert.Volume = 1.5
TDesert.Looped = true
TDesert.archivable = true
TDesert.Parent = script.Parent
task.wait(80)
TDesert:Play()
if infoWave.Value == 40 then
TDesert:Stop()
end
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
TDesert:Play()
infoWave:GetPropertyChangedSignal("Value"):Connect(function()
if infoWave.Value >= 40 and TDesert.IsPlaying == true then
TDesert:Stop()
end
end)