I was making a sound region for each of my maps on my game. The sound region WAS playing until after I died, it stopped out of the blue. Here is a YouTube video of it:
The script is fully functioning, no errors. I have no clue what even caused this to happen in the first place.
Edit: The screen recording was bad. After the music stopped playing, it teleported me back to the same map and no music was playing.
local SoundsInRegion = game.Workspace:WaitForChild("SoundsRegions")
local Found = false
while wait(1)do
for i,v in pairs(SoundsInRegion:GetChildren())do
Found = false
local region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts)do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
print("Player was Found")
Found = true
break
else
Found = false
print("Player was not Found in region")
end
end
if Found == true then
if script.Parent.Sounds[v.Name].IsPlaying == false then
script.Parent.Sounds[v.Name]:Play()
break
end
else
script.Parent.Sounds[v.Name]:Stop()
end
end
end
If its in StarterGui, the script will be deleted, then re-made on player death. To prevent this, you can put it inside a StarterGui and turn ResetOnSpawn to false. Its a property of a ScreenGui.
found this in the console. As you can see the script i put above when replying to @varjoy is the script that I was using. I don’t spy anything about “position is not a valid member of weld”.
It could be that when you use the break it actually cancels the entire loop. Maybe change your system up a bit where it doesn’t need to use that break.