local r = {}
local new = false
local loopId = 0
script.Event.Event:Connect(function(s,vol,ye)
new = false
if #r~=#s then
new = true
else
for i=1,#r do
if new==false then
if r[i]==s[i] then
new = false
else
new = true
end
end
end
end
if new==true then
r = s
loopId = loopId + 1
local id = loopId
if id ~= loopId then return end
while true do
for i = 1,#r do
if id ~= loopId then return end
script.Parent.ambience.SoundId = r[i]
if script.Parent.ambience.IsLoaded==false then
script.Parent.ambience.Loaded:Wait()
end
if ye==true then
script.Parent.ambience.Volume = 0
script.Parent.ambience:Play()
game:GetService("TweenService"):Create(script.Parent.ambience,TweenInfo.new(.5,Enum.EasingStyle.Quad),{Volume = vol}):Play()
wait(script.Parent.ambience.TimeLength)
game:GetService("TweenService"):Create(script.Parent.ambience,TweenInfo.new(.5,Enum.EasingStyle.Quad),{Volume = 0}):Play()
wait(.5)
else
script.Parent.ambience.Volume = vol
script.Parent.ambience:Play()
wait(script.Parent.ambience.TimeLength)
end
print(script.Parent.ambience.TimeLength.." leng")
print(script.Parent.ambience.TimePosition.." pos")
if id ~= loopId then return end
end
end
end
end)
Please don’t expect us to understand a code like this, what’s “s,vol,ye”? how you expect us to help you if we barely understand what’s happening or what’s this for?
You have to learn to be more humble because we’re trying to help you…
look man, I only see 2 yielding, in wait(.5) in ye == true, and .Loaded:Wait()
Which we don’t know when it fires, and this is in a while infinite loop which is not breaking neither has any yielding functions
Well, this is the code the dude sent me in my other thead and he says it’s working perfectly…
I tried t recored a video about this but it seems like it doesn’t work randomly
And also it’s 1 and 40 seconds so I can’t uploda it hear but its is here is the outboard*outputst
ill look into it and see if i can maybe write you a better code then cause this guy (no offence to him) didnt make this with any consideration to readability. its very hard to follow and clearly not a very good code anyway
Well, I dont have problems with the variables names and stuff… But I have a problem understanding what u want do achieve.
At this point what I would do is dump entirely the code and try a different approach, having in mind exactly what u are trying to achieve… maybe that helps :v
Here is place file FILEFORDEVFORUMLOLOLOL1337H4XZ0RZ.rbxl (239.0 KB)
Repro:
Just click play, walk to biome with house, wait a bit, if it works proplery retry it again and again until it doesn’t work
You really didnt describe much about whats going on at all inside your post. I think your dealing with playing audio? If you have the PlaybackSpeed different it may give diffent results with TimeLength and Position.
You shouldn’t use wait(). Instead, use event driven programming. To wait until a Sound is over use the Ended event and the Wait() function of a RBXScriptSignal (the object used for events).
For example, instead of wait(script.Parent.ambience.TimeLength)
do script.Parent.ambience.Ended:Wait()
I kinda think the same as @grif_0 and many others.
Even if I test ur file, I still dont understand what u want to achieve…
I understand better with text explanation than reading ur code.
“I want to create a playlist per biome in my game, each audio file will have a “hardcoded” delay, which I will store in a table, and depending on the biome they touch they will listen a different song, which gradually goes down in volume to blend with the next one.”
Something like that… thats enough. And I would reply an approach.
All your threads have the code in this manner, the variable names are really not understandable. Don’t expect us to know what each and every variable does that are named as ye, vol etc. Commenting and explaining what the variables do in the code would help, although not needed for this thread probably as you already explained it above.
Edit: Couldn’t identify the code properly earlier.