Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- xDarkScripter, Credit to Tinfold for idea | Client Script | Beat
- local Players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Player = Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local Camera = workspace.CurrentCamera
- local Head = Player.Character:FindFirstChild("Head")
- local BeatCounter = 1
- local Tune = {BPM = 360, BPU = 4, U = 4}
- Tune.Sounds = {}
- function Tune:NewSound(Volume, Pitch, SoundId)
- local Sound = Instance.new("Sound")
- Sound.Volume = Volume
- Sound.Pitch = Pitch
- Sound.SoundId = SoundId
- return Sound
- end
- Tune.Sounds = {
- Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173820");
- Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173898");
- Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173844");
- Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173799");
- }
- for Key, Sound in next, Tune.Sounds do
- Sound.Parent = Head
- end
- local BeatTabs = {}
- function Tune:NewBeatTab(Beat, Track, Offset)
- local BeatTabIndex = #BeatTabs + 1
- local Tab = Instance.new("Part")
- Tab.Anchored, Tab.CanCollide = true, false
- Tab.FormFactor, Tab.Material = 3, "SmoothPlastic"
- Tab.Size = Vector3.new(0.6, 0.6, 0.6)
- Tab.BrickColor = BrickColor.new("Really black")
- Tab.TopSurface = "SmoothNoOutlines"
- Tab.BottomSurface = "SmoothNoOutlines"
- Tab.LeftSurface = "SmoothNoOutlines"
- Tab.RightSurface = "SmoothNoOutlines"
- Tab.FrontSurface = "SmoothNoOutlines"
- Tab.BackSurface = "SmoothNoOutlines"
- local Click = Instance.new("ClickDetector")
- Click.MouseHoverEnter:connect(function(Activator)
- if Activator ~= Player then return end
- Tab.Size = Vector3.new(0.7, 0.7, 0.7)
- end)
- Click.MouseHoverLeave:connect(function(Activator)
- if Activator ~= Player then return end
- if BeatTabs[BeatTabIndex].Toggled == false then
- Tab.Size = Vector3.new(0.6, 0.6, 0.6)
- end
- end)
- Click.MouseClick:connect(function(Activator)
- if Activator ~= Player then return end
- Tab.Size = Vector3.new(0.7, 0.7, 0.7)
- local Toggled = BeatTabs[BeatTabIndex].Toggled
- BeatTabs[BeatTabIndex].Toggled = not Toggled
- if Toggled then
- Tab.Transparency = 0
- Tab.BrickColor = BrickColor.new("Really black")
- Tab.Material = "SmoothPlastic"
- else
- Tab.Transparency = 0.2
- Tab.BrickColor = BrickColor.new("Cyan")
- Tab.Material = "Neon"
- end
- end)
- Click.Parent = Tab
- BeatTabs[BeatTabIndex] = {BasePart = Tab, Offset = Offset, Toggled = false, Track = Track, Beat = Beat}
- return Tab
- end
- local TuneSounds = #Tune.Sounds
- local TotalBeats = Tune.U * Tune.BPU
- for Row = 1, TuneSounds do
- for Beat = 1, TotalBeats do
- local BeatTab = Tune:NewBeatTab(Beat, Row, CFrame.new((Beat - 1) * 0.8 - (TotalBeats * 0.4)
- , (Row - 1) * 0.8 - (TuneSounds * 0.4), 20 * math.abs(1 - math.cos(math.pi / 4 * ((Beat - 1) - TotalBeats / 2) / TotalBeats))))
- BeatTab.Parent = workspace
- end
- end
- function Tune:UpdateTabs()
- for Key, Tab in next, BeatTabs do
- local GoalCFrame = (Player.Character.PrimaryPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(-math.pi / 8, 0, 0)) * Tab.Offset
- Tab.BasePart.CFrame = Tab.BasePart.CFrame:Lerp(CFrame.new(GoalCFrame.p, Player.Character.PrimaryPart.Position), 0.1)
- end
- end
- function Tune:Beat()
- if BeatCounter < Tune.U * Tune.BPU then
- BeatCounter = BeatCounter + 1
- else
- BeatCounter = 1
- end
- for Key, Tab in next, BeatTabs do
- if Tab.Beat == BeatCounter and Tab.Toggled == true then
- Tune.Sounds[Tab.Track]:play()
- end
- end
- end
- local Tracker = Instance.new("Part")
- Tracker.Anchored, Tracker.CanCollide = true, false
- Tracker.FormFactor, Tracker.Material = 3, "Neon"
- Tracker.Transparency = 0.1
- Tracker.Size = Vector3.new(0.4, 0.4, 0.4)
- Tracker.BrickColor = BrickColor.White()
- Tracker.TopSurface = "SmoothNoOutlines"
- Tracker.BottomSurface = "SmoothNoOutlines"
- Tracker.LeftSurface = "SmoothNoOutlines"
- Tracker.RightSurface = "SmoothNoOutlines"
- Tracker.FrontSurface = "SmoothNoOutlines"
- Tracker.BackSurface = "SmoothNoOutlines"
- Tracker.Parent = Player.Character
- function Tune:UpdateTracker()
- local TrackerGoalCFrame = (Player.Character.PrimaryPart.CFrame * CFrame.new(0, 0, -5)
- * CFrame.Angles(-math.pi / 8, 0, 0)) * CFrame.new((BeatCounter - 1) * 0.8 - (TotalBeats * 0.4), 2, 0)
- Tracker.CFrame = Tracker.CFrame:Lerp(TrackerGoalCFrame, 0.4)
- end
- local PreviousStep
- RunService.Stepped:connect(function(Step)
- if PreviousStep then
- if Step - PreviousStep >= 60 / Tune.BPM then
- PreviousStep = Step
- Tune:Beat()
- end
- else
- PreviousStep = Step
- end
- Tune:UpdateTabs()
- Tune:UpdateTracker()
- end)
Add Comment
Please, Sign In to add comment