Everytime I try to wait for a sound effect to end this happens, any help?
This is my code
local tween = tweenservice:Create(cam, TweenInfo.new(0.4), {["CFrame"] = senpaicam.CFrame})
cam.CameraType = "Scriptable"
wait(0.4)
sfx:Play()
tween:Play()
tween.Completed:Wait()
sfxkill[math.random(1, #sfxkill)]:Play()
wait(5)
nowait:Play()
wait(3.8)
ayanosoundloc.GameOver:Play()
wait(3.7)
sfxayano[math.random(1, #sfxayano)]:Play()
sfxayano.Ended:Wait()
ayanosoundloc.GameOverTheme:Play()
Any help?
1 Like
Which line does it say the error on?
Theres a possibility that its not a tween object inside the list, but not enough context to understand
sfxayano.Ended:Wait() is the line that errors
xGOA7x
(Cairo)
February 5, 2023, 5:34am
#5
You are basically telling a table to wait until it ends, and Wait
isn’t a function within a table so I’m not sure what you expect.
Oh, well is there any way that I can wait until a randomly selected sound effect ends?
xGOA7x
(Cairo)
February 5, 2023, 5:35am
#7
Yes:
local RandomSound = sfxayano[math.random(1, #sfxayano)] -- gets Random Instance
RandomSound:Play() -- Plays Instance
RandomSound.Ended:Wait() -- Waits until Sound ends
Doing this:
local RandomSound = sfxayano[math.random(1, #sfxayano)]:Play()
will potentially make the code Error or return nil
on the Variable.
1 Like
Thank worked! Thank you very much!
system
(system)
Closed
February 19, 2023, 5:37am
#9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.