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

Why does my music only play for 1 second then it completely stops?

Asked by 6 years ago
Edited 6 years ago

As said in my title, when I test the game in an actual server, I can hear my music for a specific area just fine, but I only hear it for 1 quick second, or 2 seconds, then it just stops and does not play again. I have the music on looping as well and Filtering Enabled (If any of you ask that lol). My thought is that my character is not loading fast enough, but I am having difficulty on making a script so that my character loads first (If that is even the problem). Here is my script for the music, and keep in mind, the character spawns right inside of the "Part" and cannot leave the part and walk back in as the "Part" covers the whole map (One specific part of the Map). I did shrink the "Part" to leave and come back in, and in fact, the music does work... So that is why I think character loading is the issue... Anyways, here is the script.

script.Parent.Touched:connect(function(part)
    local plr = game.Players:GetPlayerFromCharacter(part.Parent)

    if plr then
        script.Parent.MufiaPlaza:Play()
    end
end)

script.Parent.TouchEnded:connect(function(part)
    local plr = game.Players:GetPlayerFromCharacter(part.Parent)

    if plr then
        script.Parent.MufiaPlaza:Stop()
    end
end)

The "MufiaPlaza" is the title of my Sound I have included into the "Part."

Quick Update: I have been stupid all this time and removed the Touch Ended part of the script, and when I go to test it, it works in the server fine. Now the problem is, I need that Touch Ended script so that when the character leaves the "Part," the music will stop too and play another music in a different location. (I have tried to put it in a separate script btw.)

0
Another Update: The music works half of the time in the server, but the other half, it only plays for 2 seconds and then stops... So, pretty sure character loading is the problem??? TheMagicalWell 2 — 6y

Answer this question