Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Sound not replicating on the server?

Asked by 7 years ago

I'm using FilteringEnabled, and the sounds .Ended event isn't registering, the song's properties aren't being updated on the server, only on the client. How can the server be notified that the song has ended?

local MusicLibrary = {"298810953", "378902218", "360676009", "256519229", "257739740", "446057463"}
local AmbienceLibrary = {}
-- War 256131892, 446883821

local Sounds = game.Workspace.Mechanics.Sounds
local Music = Sounds.Music
local Ambience = Sounds.Ambience

Ambience:Play()

ChangeSong=function()
    if (not Music.IsPlaying) then
        local Choice = MusicLibrary[math.random(1, #MusicLibrary)]
        Music.SoundId = "http://www.roblox.com/asset/?id="..Choice
        Music:Play()
        Music.Ended:connect(function()
        print(".")
        end)
    end
end

ChangeSong()

1 answer

Log in to vote
0
Answered by
Link150 1355 Badge of Merit Moderation Voter
7 years ago
Edited 7 years ago

It makes no sense for a server script to know when a sound has ended because it may play at a different time for every player.

What you should do instead is use a local script and a RemoveEvent object to communicate back with the server script that handles your songs.

You can read up about RemoteEvents here: http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent

And here: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial

Hope it helped; If it did please mark my answer as accepted and optionally upvote, it helps us both. ;)

Ad

Answer this question