Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to play a specific id within a brick?

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)

3 comments

0

use EmitterSize, but you can't position a Sound instance

0

sorry

0

technically you can position a sound instance, just put it in a part and move the part to the correct position, then just make the part invisible and cancollide false.

1 answer

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.

I used this answer for reference

2 comments

0

But, is it also possible to play a specific id and then have it play within the area? ill add the scripts i have in a minute

0

added the scripts

This discussion is preserved as it was. New answers, comments, and votes are closed.