i wanted a sound system with witch when clicked it chandes the image and start the song i took ai help as im a ui scripter and a modler . the ai telling me to add this script in the image button but it only changes the image does not start the audio pls help
heres the script
local imageButton = script.Parent
local currentImage = 1
local images = {"rbxassetid://14219414360", "rbxassetid://7063694142"} -- Replace with actual image asset IDs
local soundIds = {95340344094014, 95340344094014} -- Replace with actual sound asset IDs
local soundService = game:GetService("SoundService")
local sound = Instance.new("Sound", soundService)
imageButton.MouseButton1Click:Connect(function()
currentImage = currentImage % #images + 1
imageButton.Image = images[currentImage]
-- Stop any currently playing sound
if sound.IsPlaying then
sound:Stop()
end
-- Set and play the new sound
sound.SoundId = "rbxassetid://95340344094014" .. soundIds[currentImage]
sound:Play()
end)
** You are now Level 1! **