简体   繁体   中英

Why Aren't The Sounds in my Sound Group not working?

I was trying to make a music player for my game, however, when I was trying to get my sound to play it refused to work. The games output works before and after the sound, but I can't hear anything. I tried using both a folder and sound group (what I'm using currently) and both did not work. How would I fix this? I presume it has something to do with client-server but I am not sure.

 local ss = game:WaitForChild("SoundService")

local rp = game:WaitForChild("ReplicatedStorage")

local list = ss.Music:GetChildren()

rp.SongOn.OnServerEvent:Connect(function(plr)

repeat

    local num = math.random(1, #list)
    print(num)

    local track = list[num]
    local name = track.Name
    print(name)
    plr.PlayerGui.Overhead.Notch.SongTitle.Text = track.Name

    local song = ss.Music:WaitForChild(name)
    print("played")

    wait(track.TimeLength)
    print("waited length")

until

rp.SongOff.OnServerEvent

end)

在此处输入图像描述

You never play anything. You don't actually reproduce the Sound. To run a Sound, use Sound:Play()

https://create.roblox.com/docs/reference/engine/classes/Sound

Your repeat until condition is also wrong. The music will not stop playing once that event is fired, and it will actually not matter at all - when the loop finishes running once, it will compare if literally rp.SongOff.OnServerEvent evaluates to true. OnServerEvent is the literal event itself, which will be true since it is not false or nil . So the loop will stop running when it runs once.

Instead, you likely want to make a function that plays the music, and run this function whenever:

And then, bind to that stop music remote a function that stops the sound.

Also you should have some more shame, you didn't even try to hide you're making a nazi game

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM