When you are in this region it plays a piece of music, when the player is out the music stops. When i'm in the region it prints that i am out of the region, and the piece of music does not play.
Here's the script:
local RegionPart = game.Workspace.Region
local Lantern = game.Workspace.Lantern
local pos1 = RegionPart.Position - (RegionPart.Size / 2)
local pos2 = RegionPart.Position + (RegionPart.Size / 2)
local Region = Region3.new(pos1, pos2)
while true do
wait()
local PartInRegion = workspace:FindPartsInRegion3(Region, Lantern, 1000)
for i, part in pairs(PartInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
print("Player found in region"..part.Parent.Name)
local Music = game.Workspace:WaitForChild("CaveMusic")
Music:Play()
else
print(part.Parent.Name, " is not currently in the deep dark cave")
game.Workspace.CaveMusic:Stop()
break
end
end
end
