Advertisement
Prephy

Untitled

Apr 22nd, 2023
1,206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.00 KB | None | 0 0
  1. local Workspace = game:GetService("Workspace")
  2. local RunService = game:GetService("RunService")
  3.  
  4. local scriptParent = Workspace
  5. local switched = false
  6.  
  7. local Character = owner.Character
  8. script.Name = "BeepBoopSkyway"
  9. script.Parent = scriptParent
  10.  
  11. local root = Character:GetDescendants()
  12. for _,prt in ipairs(root) do
  13.     if prt:IsA("BasePart") then
  14.         root=prt
  15.         break
  16.     end
  17. end
  18.  
  19. local Music = Instance.new("Sound",root)
  20. Music.Looped = true
  21. Music.Volume = 1
  22. Music.SoundId = "rbxassetid://13206817804"
  23. Music.PlaybackSpeed = 1
  24. Instance.new("ObjectValue", script).Value = Music
  25.  
  26. Music:Play()
  27. if not Music.IsLoaded then
  28.     Music.Loaded:Wait()
  29. end
  30.  
  31. local Start = os.clock()
  32. local function updateSync()
  33.     for _, Script in ipairs(scriptParent:GetChildren()) do
  34.         if Script.ClassName == "Script" and Script.Name == "BeepBoopSkyway" and Script:GetAttribute("Start") ~= nil and tonumber(Script:GetAttribute("Start")) then
  35.             Start = tonumber(Script:GetAttribute("Start"))
  36.            
  37.             break
  38.         end
  39.     end
  40. end
  41.  
  42. scriptParent.ChildRemoved:Connect(updateSync)
  43. scriptParent.ChildAdded:Connect(updateSync)
  44. updateSync() -- Little messy, have to do this cause _G is bit messed up on LSB rn.
  45.  
  46. Music.TimePosition = (os.clock() - Start) % Music.TimeLength
  47. Music:Play()
  48.  
  49. local Highlight = Instance.new("Highlight", script)
  50. Highlight.OutlineColor = Color3.new(1,1,1)
  51. Highlight.Adornee = Character
  52. Highlight.DepthMode = Enum.HighlightDepthMode.Occluded
  53.  
  54. local NextWhiteTime = 2.5
  55. local DoNext = true
  56.  
  57. RunService.Heartbeat:Connect(function()
  58.     script:SetAttribute("Start", Start)
  59.  
  60.     local TimePosition = Music.TimePosition - 0.75
  61.  
  62.     local Time = TimePosition % 4
  63.     local FlashTime = (TimePosition * 2) % 1
  64.     local FlashValue = (Time >= 2.5 and Time < 4) and math.clamp((1 - FlashTime),0,1) or 0
  65.     local Color = (4 > (TimePosition % 8) and Color3.fromRGB(switched and 0 or 255,0,switched and 255 or 0) or Color3.fromRGB(switched and 255 or 0,0,switched and 0 or 255)):Lerp(Color3.fromRGB(255,255,255),FlashValue)
  66.  
  67.     Highlight.FillTransparency = (1 - FlashValue) / 4 + 0.25
  68.     Highlight.OutlineTransparency = 1 - FlashValue
  69.     Highlight.FillColor = Color
  70. end)
  71.  
  72. owner.Chatted:Connect(function(msg)
  73.     if string.sub(msg,1,3) == "/e " then
  74.         msg = string.sub(msg,4)
  75.     end
  76.  
  77.     if string.sub(msg,1,1) == "," then
  78.         local cmd = string.sub(msg,2)
  79.  
  80.         if string.sub(cmd,1,6) == "switch" then
  81.             switched = not switched
  82.         elseif string.sub(cmd,1,4) == "sync" then
  83.             for _, Script in ipairs(scriptParent:GetChildren()) do -- This code could be better.
  84.                 if Script.ClassName == "Script" and Script.Name == "BeepBoopSkyway" and Script:GetAttribute("Start") ~= nil and tonumber(Script:GetAttribute("Start")) then
  85.                     local SoundValue = Script:FindFirstChildOfClass("ObjectValue")
  86.                     if not SoundValue or not SoundValue.Value or SoundValue.Value.ClassName ~= "Sound" then
  87.                         continue
  88.                     end
  89.  
  90.                     SoundValue.Value.TimePosition = (os.clock() - tonumber(Script:GetAttribute("Start"))) % SoundValue.Value.TimeLength
  91.                 end
  92.             end
  93.         end
  94.     end
  95. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement