✓ Accepted answer
This is quite a simple process to accomplish. You're going somewhat the correct direction.
What you want to do when you click the GUI that is creating the Sound is have it check if a sound exists BEFORE the sound is even created.
This is what a script would look like if you were just checking.
if game.Workspace:FindFirstChild("Sound") ~= nil then
print("Sound Already Exists!!")
else
s = Instance.new("Sound", game.Workspace)
end
Now, I used FindFirstChild() because an error may occur if you go to something that is Nil !
Here is what it may look like in a GUI, but beware that my hierarchy will differ from yours!
game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(function()
if game.Workspace:FindFirstChild("Sound") ~= nil then
print("Already Exists")
else
s = Instance.new("Sound", game.Workspace)
end
end)
If this helps, UpVote and Accept!
Ask any questions if needed
2 comments
The code I did is just not making another sound, instead it will see if it's there and if so, print above. The sound doesn't get removed in this script
Remember, anything done in StarterGui will NOT replicate to the player! StarterGui is simply a holder to store GUIs that will later be cloned into your PlayerGui. Any events connected or visual changes must therefore be done in PlayerGui.