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

What is the best way to do different music zones?

Asked by 6 years ago
Edited 6 years ago

So i have a game where i would like to be able to change the music depending where they are in the map.

I have attempted to have big walls indicating the zones that they can be in and when they touch a wall, it will delete other sounds playing for them?

Is there a better way to do this, because this doesn't feel too efficient.

Thank you.

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I would look into Region3's, but I don't think they would be more efficient than what you're doing because you can't actually see a Region3, and they would take much longer to create compared to a part.

What I would suggest doing though is putting all your walls into ReplicatedFirst. The server cant access ReplicatedFirst, so less load on the server.

Then you can clone all the walls in ReplicatedFirst from a local script and put them in workspace, so the server doesn't have to handle the touch events.

Assuming your game is FilteringEnabled

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

LAZIEST WAY:

Make a giant invisible part which is no collide that encompasses a certain zone.
then do this:

  1. use the part touched command to start the music.

Ex.

game.Workspace.MusicZone1part.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        (play music)
    end
end)
  1. Once the zone is left, turn off the music with the TouchEnded command

Ex.

game.Workspace.MusicZone1part.TouchedEnded:connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        (stop music)
    end
end)

also u may wanna use an if statement if certain zones have the same audio or something else to say something like (if this audio is already playing, don't try to restart it)

I MADE U A partially WORKING EXAMPLE:

https://www.roblox.com/library/1878437547/saodsijadoij

0
That's similar to what I'm currently doing, I was just wondering if there was a better/different way to do this. PoePoeCannon 519 — 6y
Log in to vote
-1
Answered by 6 years ago

Raycast

Answer this question