Hi!
Really nothing else is needed. I recycled an old Theme script, so it’s pretty messy. I hear the clicks at the start, but nothing happens when I click the buttons.
Thanks!
local a = 0
local b = 0
local ended = false
local SOUND = script.Sound
function RemoveTableDupes(tab)
local hash = {}
local res = {}
for _,v in ipairs(tab) do
if (not hash[v]) then
res[#res+1] = v
hash[v] = true
end
end
return res
end
task.wait(15)
local OBJECTS = {}
for i, obj in pairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetDescendants()) do
if obj:IsA("GuiObject") and obj.Parent ~= script.Parent and obj.Parent.Parent ~= script.Parent then
--Found a GuiObject
if obj:IsA("ImageButton") then
a += 1
table.insert(OBJECTS, obj)
end
elseif obj:IsA("TextButton") then
a+=1
table.insert(OBJECTS, obj)
end
end
OBJECTS = RemoveTableDupes(OBJECTS)
function OpenLoading()
local frame = game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame
frame.Visible = true
frame.lab.Text = "Initalizing..."
task.wait(2)
end
function CloseLoading()
local frame = game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame
frame.Visible = false
end
local function SetAllColors(color)
for i, obj in pairs(OBJECTS) do
if obj:IsA("GuiObject") and obj.Parent ~= script.Parent and obj.Parent.Parent ~= script.Parent then
--Found a GuiObject
task.wait()
if obj:IsA("ImageButton") or obj:IsA("ImageLabel") then
b += 1
local e = Instance.new("Sound")
e.SoundId = "rbxassetid://178104975"
e.Volume = 2
e.Parent = obj
e:Play()
obj.MouseButton1Click:Connect(function()
e:Play()
end)
end
elseif obj:IsA("TextButton") then
b += 1
local e = Instance.new("Sound")
e.SoundId = "rbxassetid://178104975"
e.Volume = 2
e.Parent = obj
e:Play()
obj.MouseButton1Click:Connect(function()
e:Play()
end)
end
end
end
game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame.lab.Text = "Loading.. ["..b.."/"..a.."]"
ended = true
SetAllColors(game.Players.LocalPlayer:WaitForChild("Theme").Value)
local a = 0
local b = 0
local ended = false
local SOUND = script.Sound
function RemoveTableDupes(tab)
local hash = {}
local res = {}
for _,v in ipairs(tab) do
if (not hash[v]) then
res[#res+1] = v
hash[v] = true
end
end
return res
end
task.wait(15)
local OBJECTS = {}
for i, obj in pairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetDescendants()) do
if obj:IsA("GuiObject") and obj.Parent ~= script.Parent and obj.Parent.Parent ~= script.Parent then
--Found a GuiObject
if obj:IsA("ImageButton") then
a += 1
table.insert(OBJECTS, obj)
end
elseif obj:IsA("TextButton") then
a+=1
table.insert(OBJECTS, obj)
end
end
OBJECTS = RemoveTableDupes(OBJECTS)
function OpenLoading()
local frame = game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame
frame.Visible = true
frame.lab.Text = "Initalizing..."
task.wait(2)
end
function CloseLoading()
local frame = game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame
frame.Visible = false
end
local function SetAllColors(color)
for i, obj in pairs(OBJECTS) do
if obj:IsA("GuiObject") and obj.Parent ~= script.Parent and obj.Parent.Parent ~= script.Parent then
--Found a GuiObject
task.wait()
if obj:IsA("ImageButton") then
b += 1
local e = Instance.new("Sound")
e.SoundId = "rbxassetid://178104975"
e.Volume = 2
e.Parent = script
e:Play()
local scr = script.LocalScript:Clone()
scr.Parent = obj.Parent
scr.Disabled = false
e:Destroy()
end
elseif obj:IsA("TextButton") then
b += 1
local e = Instance.new("Sound")
e.SoundId = "rbxassetid://178104975"
e.Volume = 2
e.Parent = obj
e:Play()
local scr = script.LocalScript:Clone()
scr.Parent = obj.Parent
scr.Disabled = false
e:Destroy()
end
end
end
game.Players.LocalPlayer.PlayerGui.ChangeSetting.Frame.lab.Text = "Loading.. ["..b.."/"..a.."]"
ended = true
SetAllColors(game.Players.LocalPlayer:WaitForChild("Theme").Value)
I don’t have the time to go through the whole script but I understand that you want to have one script do the work for all of the buttons and play the sound when you click them?
local plr = game.Players.LocalPlayer
local sound = script.Sound -- the reason I did this is just so it's easier for you to understand but if you have a other place where you store sounds set the path to that, but you can put the sound inside the script
-- looping throught the buttons --
for i, button in pairs(buttonsHolder:GetChildren()) do
button.MouseButton1Click:Connect(function()
sound:Play()
end
end
Also I think you create a multiple sounds? There’s no need for that, you can just use one.