qsenko1

super laggy regions3 script

Jul 24th, 2021
1,198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- It Works but laggs the game a ton thats whu i consider it broken
  2.  
  3. local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")   --comment from here
  4. local HellSky = game.Lighting.Sky
  5. local Found = false
  6. --local Found2 = false
  7. --local music = game.SoundService["Santa Tell Me"]
  8. local Character = game.Players.LocalPlayer.Character
  9. local Humanoid = Character:FindFirstChild("Humanoid")
  10. --local mute = game.StarterGui.MusicGui.Frame["Mute/Unmute Music"]
  11.  
  12. game:GetService("RunService").Stepped:connect(function()
  13. while wait(1)do
  14.    
  15.     for i , v in pairs(SoundRegionsWorkspace:GetChildren())do
  16.        
  17.         Found = false
  18.         --Found2 = false
  19.         local region = Region3.new(v.Position -(v.Size/2),v.Position + (v.Size/2))
  20.     --  local mute = game.StarterGui.MusicGui.Frame["Mute/Unmute Music"]
  21.         local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
  22.        
  23.         for _, parts in pairs(parts)do
  24.             --Loop one by one trought the parts table
  25.             if parts:FindFirstAncestor(game.Players.LocalPlayer.Name)then
  26.                 --print("Player was found")
  27.                 Found = true
  28.         --      Found2 = true
  29.  
  30.                 break
  31.             else
  32.                 Found = false
  33.         --      Found2 = false
  34.                 --print("Player was not found in region")
  35.             end
  36.         end
  37.         if Found == true and v.Name == "HellTower" then
  38.         --  print("HellFound")
  39.         --  script.Parent.RegionSounds.PinkTower.IsPlaying = false
  40.             script.Parent.RegionSounds.PinkTower:Stop()
  41.             script.Parent.RegionSounds.WhiteTower:Stop()
  42.             script.Parent.RegionSounds.DarkTower:Stop()
  43.             script.Parent.RegionSounds.YellowTower:Stop()
  44.             if script.Parent.RegionSounds.HellTower.IsPlaying == false then
  45.                 script.Parent.RegionSounds.HellTower:Play()
  46.                 --script.Parent.RegionSounds[v.Name]:Play()
  47.                 HellSky.SkyboxBk = "http://www.roblox.com/asset/?id=227620983"
  48.                 HellSky.SkyboxDn = "http://www.roblox.com/asset/?id=227621004"
  49.                 HellSky.SkyboxFt = "http://www.roblox.com/asset/?id=227621032"
  50.                 HellSky.SkyboxLf = "http://www.roblox.com/asset/?id=227621047"
  51.                 HellSky.SkyboxRt = "http://www.roblox.com/asset/?id=227621090"
  52.                 HellSky.SkyboxUp = "http://www.roblox.com/asset/?id=227621130"
  53.             --  music.Volume = 0
  54.                 break
  55.             --else
  56.             --  return
  57.             end
  58.         end
  59.    
  60.         if Found == true and v.Name == "PinkTower" then
  61.             script.Parent.RegionSounds.HellTower:Stop()
  62.             script.Parent.RegionSounds.WhiteTower:Stop()
  63.             script.Parent.RegionSounds.DarkTower:Stop()
  64.             script.Parent.RegionSounds.YellowTower:Stop()
  65.             if script.Parent.RegionSounds.PinkTower.IsPlaying == false then
  66.                 script.Parent.RegionSounds.PinkTower:Play()
  67.                 HellSky.SkyboxBk = "http://www.roblox.com/asset/?id=265122679"
  68.                 HellSky.SkyboxDn = "http://www.roblox.com/asset/?id=265122712"
  69.                 HellSky.SkyboxFt = "http://www.roblox.com/asset/?id=265122728"
  70.                 HellSky.SkyboxLf = "http://www.roblox.com/asset/?id=265122757"
  71.                 HellSky.SkyboxRt = "http://www.roblox.com/asset/?id=265122796"
  72.                 HellSky.SkyboxUp = "http://www.roblox.com/asset/?id=265122846"     
  73.                 break
  74.             --else
  75.             --  return
  76.             end
  77.         end
  78.        
  79.         if Found == true and v.Name == "Lobby" then
  80.             script.Parent.RegionSounds.PinkTower:Stop()
  81.             script.Parent.RegionSounds.HellTower:Stop()
  82.             script.Parent.RegionSounds.WhiteTower:Stop()
  83.             script.Parent.RegionSounds.DarkTower:Stop()
  84.             script.Parent.RegionSounds.YellowTower:Stop()
  85.             HellSky.SkyboxBk = "rbxasset://textures/sky/sky512_bk.tex"
  86.             HellSky.SkyboxDn = "rbxasset://textures/sky/sky512_dn.tex"
  87.             HellSky.SkyboxFt = "rbxasset://textures/sky/sky512_ft.tex"
  88.             HellSky.SkyboxLf = "rbxasset://textures/sky/sky512_lf.tex"
  89.             HellSky.SkyboxRt = "rbxasset://textures/sky/sky512_rt.tex"
  90.             HellSky.SkyboxUp = "rbxasset://textures/sky/sky512_up.tex" 
  91.         --else
  92.             --  return
  93.             break
  94.         end        
  95.        
  96.         if Found == true and v.Name == "ChocolateTower" then
  97.             script.Parent.RegionSounds.PinkTower:Stop()
  98.             script.Parent.RegionSounds.HellTower:Stop()
  99.             script.Parent.RegionSounds.WhiteTower:Stop()
  100.             script.Parent.RegionSounds.DarkTower:Stop()
  101.             script.Parent.RegionSounds.YellowTower:Stop()
  102.             HellSky.SkyboxBk = "http://www.roblox.com/asset/?version=1&id=1014350"
  103.             HellSky.SkyboxDn = "http://www.roblox.com/asset/?version=1&id=1014351"
  104.             HellSky.SkyboxFt = "http://www.roblox.com/asset/?version=1&id=1014348"
  105.             HellSky.SkyboxLf = "http://www.roblox.com/asset/?version=1&id=1014349"
  106.             HellSky.SkyboxRt = "http://www.roblox.com/asset/?version=1&id=1014347"
  107.             HellSky.SkyboxUp = "http://www.roblox.com/asset/?version=1&id=1014352"
  108.         --else
  109.             --  return
  110.             break
  111.         end        
  112.        
  113.         if Found == true and v.Name == "WhiteTower" then
  114.             script.Parent.RegionSounds.PinkTower:Stop()
  115.             script.Parent.RegionSounds.HellTower:Stop()    
  116.             script.Parent.RegionSounds.DarkTower:Stop()
  117.             script.Parent.RegionSounds.YellowTower:Stop()
  118.             if script.Parent.RegionSounds.WhiteTower.IsPlaying == false then
  119.                 script.Parent.RegionSounds.WhiteTower:Play()
  120.                 HellSky.SkyboxBk = "http://www.roblox.com/asset/?id=383769914"
  121.                 HellSky.SkyboxDn = "http://www.roblox.com/asset/?id=383770103"
  122.                 HellSky.SkyboxFt = "http://www.roblox.com/asset/?id=383770028"
  123.                 HellSky.SkyboxLf = "http://www.roblox.com/asset/?id=383769973"
  124.                 HellSky.SkyboxRt = "http://www.roblox.com/asset/?id=383769873"
  125.                 HellSky.SkyboxUp = "http://www.roblox.com/asset/?id=383770066" 
  126.         --  else
  127.                 --      return
  128.                 break
  129.             end
  130.         end
  131.        
  132.         if Found == true and v.Name == "DarkTower" then        
  133.             script.Parent.RegionSounds.PinkTower:Stop()
  134.             script.Parent.RegionSounds.HellTower:Stop()
  135.             script.Parent.RegionSounds.WhiteTower:Stop()
  136.             script.Parent.RegionSounds.YellowTower:Stop()
  137.             if script.Parent.RegionSounds.DarkTower.IsPlaying == false then
  138.                script.Parent.RegionSounds.DarkTower:Play()
  139.             HellSky.SkyboxBk = "http://www.roblox.com/asset/?id=48020371"
  140.             HellSky.SkyboxDn = "http://www.roblox.com/asset/?id=48020144"
  141.             HellSky.SkyboxFt = "http://www.roblox.com/asset/?id=48020234"
  142.             HellSky.SkyboxLf = "http://www.roblox.com/asset/?id=48020211"
  143.             HellSky.SkyboxRt = "http://www.roblox.com/asset/?id=48020254"
  144.             HellSky.SkyboxUp = "http://www.roblox.com/asset/?id=48020383"  
  145.         --  else
  146.                 --      return
  147.                 break
  148.            end         
  149.         end
  150.        
  151.         if Found == true and v.Name == "YellowTower" then  
  152.             script.Parent.RegionSounds.PinkTower:Stop()
  153.             script.Parent.RegionSounds.HellTower:Stop()
  154.             script.Parent.RegionSounds.WhiteTower:Stop()
  155.             script.Parent.RegionSounds.DarkTower:Stop()
  156.             if script.Parent.RegionSounds.YellowTower.IsPlaying == false then
  157.                 script.Parent.RegionSounds.YellowTower:Play()
  158.                 HellSky.SkyboxBk = "http://www.roblox.com/asset/?id=383769715"
  159.                 HellSky.SkyboxDn = "http://www.roblox.com/asset/?id=383769835"
  160.                 HellSky.SkyboxFt = "http://www.roblox.com/asset/?id=383769760"
  161.                 HellSky.SkyboxLf = "http://www.roblox.com/asset/?id=383769739"
  162.                 HellSky.SkyboxRt = "http://www.roblox.com/asset/?id=383769680"
  163.                 HellSky.SkyboxUp = "http://www.roblox.com/asset/?id=383769794" 
  164.         --  else
  165.                 --      return
  166.                 break
  167.             end        
  168.         end
  169.    
  170.     end
  171. end
  172. end)
  173.  --[[script.Parent.RegionSounds[v.Name]:Stop()
  174.             HellSky.SkyboxBk = "rbxasset://textures/sky/sky512_bk.tex"
  175.             HellSky.SkyboxDn = "rbxasset://textures/sky/sky512_dn.tex"
  176.             HellSky.SkyboxFt = "rbxasset://textures/sky/sky512_ft.tex"
  177.             HellSky.SkyboxLf = "rbxasset://textures/sky/sky512_lf.tex"
  178.             HellSky.SkyboxRt = "rbxasset://textures/sky/sky512_rt.tex"
  179.             HellSky.SkyboxUp = "rbxasset://textures/sky/sky512_up.tex" 
  180.             print("Outside Pink")--]]
RAW Paste Data