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

How to put different music in different zones?

Asked by 6 years ago

Alright, so. I'm currently scripting and making a Rolplay game for the Book Series Warriors, called Destiny of The Stars. I'd like to make it so that in the different Zones of the Clans, and the Spawn Area, different music plays, instead of it having just one, single, boring music that loops the whole time you're playing said RPG. Though, I do not know how to do this since I'm new to scripting. Any ideas?

1
Thankfully, this does not require any scripting what so ever! Go to the location you want the music to play, and Insert an object called "Sound". I recommend making it a child of something like a Part and making it invisible. In the sound properties, simply set the MaxDistance to a lower value, and you should be set! User#20989 0 — 6y
0
Oh, I didn't think of that! Thank you! ^.^ Kozybee 4 — 6y

1 answer

Log in to vote
0
Answered by
ee0w 458 Moderation Voter
6 years ago
Edited 6 years ago

xaquizono's solution may be okay for you, but there's another way you can do this. Firstly, insert a Sound into Workspace (client or server-sided, doesn't matter). Next, have a part that acts as an "area" that the player will walk in. When the part is touched, the sound will play. When the part gets untouched, it will stop (or switch).

The script is fairly simple;

-- LocalScript
local sound = workspace:WaitForChild("Sound")
local hitbox = workspace:WaitForChild("Area1") -- Assuming we have a part in workspace called Area1
hitbox.Touched:Connect(function(part)
   if part.Name == "Head" and part.Parent.Name == game.Players.LocalPlayer.Name then
      sound.SoundId = "rbxassetid://" .. "Your sound ID"
      sound:Play() -- Highly recommended to loop the sound
      hitbox.TouchEnded:Wait() -- Yields the script until the part isn't touched anymore 
      sound:Stop()
   end
end)
Ad

Answer this question