You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
the music to be played in the part only so only people inside the part can hear it -
What is the issue? Include screenshots / videos if possible!
sound can be heard in other parts of the map -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local part = script.Parent
local clickDetector = part:FindFirstChild("ClickDetector")
local musicBlock = game.Workspace:FindFirstChild("MusicBlock")
if clickDetector and musicBlock then
local sound = musicBlock:FindFirstChild("Sound")
if sound then
local newSoundId = "rbxassetid://103558743565569"
clickDetector.MouseClick:Connect(function(player)
local distance = (musicBlock.Position - player.Character.HumanoidRootPart.Position).magnitude
sound.SoundId = newSoundId
sound.Pitch = 0.35
sound:Play()
end)
else
warn("Sound not found inside MusicBlock")
end
else
warn("ClickDetector or MusicBlock not found")
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.