Area Only Music

What im Trying to Achieve : Music only supposed to play in a certain area and the Music is the Sound ID provided by the Player in the TextBox but it dosent eem to be working

game.Players.PlayerAdded:Connect(function(plr)
local Music = script.Parent.Music
local Area = script.Parent

local Main = plr.PlayerGui:WaitForChild(“Main”)
local Slot7 = Main.Frame.Slot7
local Text = Slot7.Text
Music.SoundId = Text

wait(1)
Music.Playing = true
end)

What is not working more specifically?`

Making sound play at all or restricting it to certain areas?

Hi,
1)Please avoid using wait, it can cause some errors/issues sometimes. I’d recommend using task.wait or runservice instead. They’re better and more efficient.

2)You can use a remote function [if you want the server to be affected from this], and then invoke it , and when the player has entered that specific area, that music will be playing.

  1. If you want it to be playing only for him, you can either fire/invoke a remote, and from there, you could fire that client all you need [ so in that way, it’d be affected only on him, but from the server, which is always preferred].

And, eventually, you could make it so that while that player is in that part region, he’d be hearing that song.

For this, you should use ZonePlus. Whenever a player enters the zone, you can find their PlayerGui, find the ScreenGui, find the Frame, find the Sound, and play it. Whenever the player leaves the zone, you can stop the sound. You can find the API for ZonePlus here: Introduction - ZonePlus

1 Like