Can someone help me figure out what's wrong with my script? I have tried to fix it several times. It's supposed to play music when you walk into specific areas. I followed this tutorial exactly. https://www.youtube.com/watch?v=L_Jga2MgRdU local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions") local Found = false while wait(1) do for i, v in pairs(SoundRegionsWorkspace: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 -- Loop one by one through the parts table 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 --start playing some music if script.Parent.SoundRegions[v.Name].IsPlaying == false then script.Parent.SoundRegions[v.Name]:play() break end else script.Parent.SoundRegions[v.Name]:Stop() end end end
Not an answer - posting code block for them
local SoundRegionsWorkspace = game.Workspace:WaitForChild(“SoundRegions”) local Found = false while wait(1) do for i, v in pairs(SoundRegionsWorkspace: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 – Loop one by one through the parts table 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 --start playing some music if script.Parent.SoundRegions[v.Name].IsPlaying == false then script.Parent.SoundRegions[v.Name]:play() break end else script.Parent.SoundRegions[v.Name]:Stop() end end end
Tell me if I put it together incorrectly