--================================================== -- CONFIGURATION AND ASSET DOWNLOAD --================================================== -- Define the remote music URL and the local file name. local url = "https://raw.githubusercontent.com/helloguyswelcometoanewvideo/musics-foruse-someday/main/ladancinamuchodance.mp3" local file = "ladancinamuchodance.mp3" -- Download the music only if the file does not already exist. if not isfile(file) then local data = game:HttpGet(url) -- Validate the downloaded data before saving it. if #data >= 1000 then writefile(file, data) end end --================================================== -- SERVICE INITIALIZATION --================================================== -- Get the Roblox services required by the script. local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local SoundService = game:GetService("SoundService") -- Store a reference to the local player. local player = Players.LocalPlayer --================================================== -- LOADING NOTIFICATION --================================================== -- Display a notification when the controls are initialized. game.StarterGui:SetCore("SendNotification", { Title = "loading..", Text = "Dance controls loaded", Duration = 15 }) -- Allow time for the notification to appear. task.wait(3) --================================================== -- MUSIC INITIALIZATION --================================================== -- Create and configure the background music instance. local sound = Instance.new("Sound") sound.SoundId = getcustomasset(file) sound.Volume = 2 sound.Looped = true sound.Parent = SoundService --================================================== -- HELPER FUNCTIONS --================================================== -- Resolve an animation asset into its AnimationId. -- Return the original asset ID if no Animation object is found. local function anim2track(asset_id) local objs = game:GetObjects(asset_id) for i = 1, #objs do if objs[i]:IsA("Animation") then return objs[i].AnimationId end end return asset_id end -- Get the current character's Humanoid. -- Wait for the character to spawn if necessary. local function getHumanoid() local char = player.Character or player.CharacterAdded:Wait() return char:WaitForChild("Humanoid") end --================================================== -- ANIMATION ASSET CONFIGURATION --================================================== -- Load the asset IDs for the three dance animations. local animid = anim2track("rbxassetid://129991743366120") local animation = Instance.new("Animation") animation.AnimationId = animid local anim2id = anim2track("rbxassetid://103108681887836") local animation2 = Instance.new("Animation") animation2.AnimationId = anim2id local anim3id = anim2track("rbxassetid://112931882473990") local animation3 = Instance.new("Animation") animation3.AnimationId = anim3id --================================================== -- ANIMATION TRACK REFERENCES --================================================== -- Store the AnimationTrack objects after they are loaded. local track local track2 local track3 --================================================== -- ANIMATION LOADING --================================================== -- Create an Animator if needed and load all three animations. local function loadAnimations() local humanoid = getHumanoid() -- Find the existing Animator or create a new one. local animator = humanoid:FindFirstChildOfClass("Animator") if not animator then animator = Instance.new("Animator") animator.Parent = humanoid end -- Load each animation and assign its playback priority. track = animator:LoadAnimation(animation) track.Priority = Enum.AnimationPriority.Movement track2 = animator:LoadAnimation(animation2) track2.Priority = Enum.AnimationPriority.Movement track3 = animator:LoadAnimation(animation3) track3.Priority = Enum.AnimationPriority.Movement end -- Initialize the animation tracks. loadAnimations() --================================================== -- PLAYBACK STATE --================================================== -- Track whether playback is enabled and which dance is selected. local playing = true local activeDance = 1 --================================================== -- ANIMATION CONTROL FUNCTIONS --================================================== -- Stop all currently loaded dance animations. local function stopAnimations() if track then track:Stop() end if track2 then track2:Stop() end if track3 then track3:Stop() end end -- Play the selected dance and stop the other animations. local function playDance(index) -- Prevent dance animations from playing when playback is disabled. if not playing then return end if index == 1 then if track2 then track2:Stop() end if track3 then track3:Stop() end -- Start the first dance only if it is not already playing. if track and not track.IsPlaying then track:Play() end elseif index == 2 then if track then track:Stop() end if track3 then track3:Stop() end -- Start the second dance only if it is not already playing. if track2 and not track2.IsPlaying then track2:Play() end elseif index == 3 then if track then track:Stop() end if track2 then track2:Stop() end -- Start the third dance only if it is not already playing. if track3 and not track3.IsPlaying then track3:Play() end end -- Save the currently selected dance index. activeDance = index end --================================================== -- MUSIC AND ANIMATION PLAYBACK TOGGLE --================================================== -- Toggle music and dance playback on or off. local function togglePlayback() playing = not playing if playing then -- Resume the music and the currently selected dance. sound:Play() playDance(activeDance) else -- Stop the music and all dance animations. sound:Stop() stopAnimations() end end --================================================== -- INITIAL PLAYBACK --================================================== -- Start the background music and the first dance. sound:Play() if track then track:Play() end --================================================== -- CHARACTER RESPAWN HANDLING --================================================== -- Reload animation tracks when the player respawns. player.CharacterAdded:Connect(function() task.wait(1) loadAnimations() -- Resume the selected dance if playback is enabled. if playing then playDance(activeDance) end end) --================================================== -- MOBILE GUI INITIALIZATION --================================================== -- Get the player's GUI container. local playerGui = player:WaitForChild("PlayerGui") -- Remove an existing copy to prevent duplicate interfaces. local oldGui = playerGui:FindFirstChild("DanceMobileControls") if oldGui then oldGui:Destroy() end --================================================== -- SCREEN GUI CONFIGURATION --================================================== -- Create the main screen interface. local gui = Instance.new("ScreenGui") gui.Name = "DanceMobileControls" gui.ResetOnSpawn = false gui.IgnoreGuiInset = true gui.DisplayOrder = 10000 gui.ZIndexBehavior = Enum.ZIndexBehavior.Global gui.Parent = playerGui --================================================== -- CONTROL PANEL LAYOUT --================================================== -- Create a transparent panel to hold the control buttons. local panel = Instance.new("Frame") panel.Name = "DancePanel" panel.AnchorPoint = Vector2.new(1, 0) panel.Position = UDim2.new(1, -8, 0, 8) panel.Size = UDim2.new(0, 60, 0, 220) panel.BackgroundTransparency = 1 panel.BorderSizePixel = 0 panel.Parent = gui -- Arrange the buttons vertically with consistent spacing. local layout = Instance.new("UIListLayout") layout.Padding = UDim.new(0, 5) layout.HorizontalAlignment = Enum.HorizontalAlignment.Center layout.VerticalAlignment = Enum.VerticalAlignment.Top layout.Parent = panel --================================================== -- REUSABLE BUTTON FACTORY --================================================== -- Create a styled text button and connect its callback. local function makeButton(label, callback) local button = Instance.new("TextButton") -- Configure the button's identity and dimensions. button.Name = "Button" .. label button.Size = UDim2.new(1, 0, 0, 48) -- Configure the button's appearance. button.BackgroundTransparency = 1 button.BorderSizePixel = 0 button.TextColor3 = Color3.fromRGB(255, 255, 255) button.Text = label button.TextScaled = true button.Font = Enum.Font.GothamBold -- Enable interaction and configure rendering order. button.Active = true button.Selectable = true button.ZIndex = 100 button.Parent = panel -- Add a colored outline to the button. local stroke = Instance.new("UIStroke") stroke.Color = Color3.fromRGB(255, 80, 80) stroke.Thickness = 1.5 stroke.Transparency = 0 stroke.Parent = button -- Add rounded corners to the button. local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 8) corner.Parent = button -- Execute the supplied callback when the button is activated. button.Activated:Connect(callback) return button end --================================================== -- DANCE SELECTION BUTTONS --================================================== -- Select dance animation 1. -- Pressing the same button again does not stop the animation. makeButton("1", function() playDance(1) end) -- Select dance animation 2. makeButton("2", function() playDance(2) end) -- Select dance animation 3. makeButton("3", function() playDance(3) end) --================================================== -- MUSIC TOGGLE BUTTON --================================================== -- Keep the music control independent of dance selection. local musicButton musicButton = makeButton("OFF", function() togglePlayback() -- Update the button label to reflect the playback state. musicButton.Text = playing and "OFF" or "ON" end) --================================================== -- KEYBOARD INPUT HANDLING --================================================== -- Handle keyboard shortcuts for playback and dance selection. UserInputService.InputBegan:Connect(function(input, processed) -- Ignore inputs already handled by Roblox or another interface. if processed then return end -- Press P to toggle music and dance playback. if input.KeyCode == Enum.KeyCode.P then togglePlayback() musicButton.Text = playing and "OFF" or "ON" -- Press Z to select dance animation 1. elseif input.KeyCode == Enum.KeyCode.Z then playDance(1) -- Press X to select dance animation 2. elseif input.KeyCode == Enum.KeyCode.X then playDance(2) -- Press C to select dance animation 3. elseif input.KeyCode == Enum.KeyCode.C then playDance(3) end end)