I am trying to do GetChildren() on a folder, but it comes back as nothing. The folder constantly has Sounds going in and out, so how would I go about trying to make it find the Child every time a new Sound is added into the folder? I already tried combining the scripts, but it was a mess.
Here is the script that works with the Folder, it puts the cloned Sound into the Current Song Folder:
local starterGui = game:GetService("StarterGui")
local shuffleBtn = script.Parent
local musicFolder = starterGui.MusicGui:WaitForChild("MusicFolder")
local songs = musicFolder:GetChildren()
local currentSongFolder = starterGui.MusicGui:WaitForChild("CurrentSongFolder")
shuffleBtn.MouseButton1Click:Connect(function()
currentSongFolder:ClearAllChildren()
wait(0.5)
local chosenSong = songs[math.random(1, #songs)]
local songClone = chosenSong:Clone()
songClone.Parent = songClone
songClone:Play()
end)
And here is the code where I am trying to make it so when a new Sound is added, it will look to see if a Child was Added to the Current Song folder:
local starterGui = game:GetService("StarterGui")
local sliderBG = script.Parent
local slider = sliderBG:WaitForChild("Slider")
local currentSongFolder = starterGui.MusicGui:WaitForChild("CurrentSongFolder")
local currentSong = currentSongFolder:GetChildren()
local mouse = game.Players.LocalPlayer:GetMouse()
local snapAmount = 1
local pixelsFromEdge = 1
local movingSlider = false
slider.MouseButton1Down:Connect(function()
movingSlider = true
end)
slider.MouseButton1Up:Connect(function()
movingSlider = false
end)
mouse.Button1Up:Connect(function()
movingSlider = false
end)
mouse.Move:Connect(function()
if movingSlider then
local xOffset = math.floor((mouse.X - sliderBG.AbsolutePosition.X) / snapAmount + 0.5) * snapAmount
local xOffsetClamped = math.clamp(xOffset, pixelsFromEdge, sliderBG.AbsoluteSize.X - pixelsFromEdge)
local sliderPosNew = UDim2.new(0, xOffsetClamped, slider.Position.Y)
slider.Position = sliderPosNew
local roundedAbsSize = math.floor(sliderBG.AbsoluteSize.X / snapAmount + 0.5) * snapAmount
local roundedOffsetClamped = math.floor(xOffsetClamped / snapAmount + 0.5) * snapAmount
local sliderValue = roundedOffsetClamped / roundedAbsSize
currentSong.Volume = sliderValue
end
end)
####Re-edited by JesseSONG!

2 comments
No clue why the Code didn't inline.. First time it has messed up that bad... Yikes..
See help, to know how to properly use code blocks: https://scriptinghelpers.org/help/how-post-good-questions-answers