I'm not sure if you can do this but can you have a music player which plays a specific music id within an area of a brick only. I know that you can do this with sound environments that have a script preset with the id but I'm not sure if there's a way to play a id within a game. This is not a request I just wanna know if its possible, im fairly new to scripting. I have all the scripts to play the actual id I'm just not sure if or how I can contain it within a brick.
local SG = game:GetService("StarterGui") local P = game:GetService("Players") local B = game.Workspace:WaitForChild("Radio") or game.Workspace:FindFirstChild("Radio") local Debounce = false P.PlayerAdded:connect(function(player) if player ~= nil and Debounce == false then Debounce = true if B and Debounce == true then if B.Brain.MainWall:FindFirstChild("RadioSurfaceGui") then -- local Gui = B.Brain.MainWall:FindFirstChild("RadioSurfaceGui") if Gui then Gui.Parent = SG if SG:FindFirstChild("RadioJSurfaceGui") then local RealGui = SG:FindFirstChild("RadioSurfaceGui") if RealGui then RealGui.Adornee = B.Brain.MainWall wait() Debounce = false end end end else if not B.Brain.MainWall:FindFirstChild("DRadioSurfaceGui") then warn("Don't move the SurfaceGui into StarterGui!") end end end end end)
Script to playthe music
local TB = script.Parent.Parent.TopBox local BP = game.Workspace.Radio local Pattern = "^%d+$" script.Parent.MouseButton1Click:connect(function() if TB.Text:match(Pattern) then BP.Sound.SoundId = "http://www.roblox.com/asset/?id=" .. TB.Text BP.Sound:Play() wait(1) TB.ClearTextOnFocus = true TB.Text = "Click here, type an Audio ID, then click Enter" TB.LocalScript.Disabled = true wait() TB.LocalScript.Disabled = false else if not TB.Text:match(Pattern) then TB.ClearTextOnFocus = true TB.Text = "Invalid Audio ID" wait(1.5) TB.Text = "Click here, type an Audio ID, then click Enter" end end end)
Script to stop the music
local TB = script.Parent.Parent.TopBox local BP = game.Workspace.Radio script.Parent.MouseButton1Click:connect(function() BP.Sound:Stop() BP.Sound1:Stop() end)
If you're talking about playing audio in a specific area, then it's possible.
A good method of doing it is checking Region3 if the player is in the desired region of said music and of course, if it is, then plays the desired music. When they leave, stop the music.
Another method that really shouldn't be used but you can do it is when the player touches a part to enter the said region, it starts the music and however, you set up the area you stop the music when another condition arises.