Hello, basically i’m trying to replicate a system like this which only I’m able to access. Once you put in a sound ID it gets played via sound bricks. But the problem is I dont know how to do it. It would be absolutely grand if someone could design one for me. Adding on, the UI can only be accessed by using a proximity prompt on an object.
Hello there! It sounds like you’re looking to create a system where you can input a sound ID, and when triggered, the sound is played through sound bricks. Additionally, you want to restrict access to this system by using a proximity prompt on an object. I’d be happy to assist you with that!
To start off, let’s break down the process into a few steps:
Create a UI for inputting the sound ID:
Design a user interface (UI) that allows you to input the sound ID. You can use Roblox’s built-in UI components such as TextBox or ImageButton to achieve this.
Make sure the UI is hidden initially and only appears when the proximity prompt is activated.
Implement the proximity prompt:
Place an object in your game that will serve as the trigger for accessing the UI. This object should have a ProximityPrompt attached to it.
Set up the ProximityPrompt to display the UI when the player enters its range. You can use the PromptShown event to show the UI and PromptHidden event to hide it.
Play the sound using sound bricks:
When the sound ID is entered in the UI and submitted, use the SoundService in Roblox to play the sound.
You can create a function that handles the sound playback, and call it when the UI submit button is pressed or the sound ID is confirmed.
Here’s an example to give you a better idea:
-- Step 1: Create a UI for inputting the sound ID
-- Define UI elements (e.g., TextBox, SubmitButton) and position them accordingly
local soundIDTextBox = script.Parent.SoundIDTextBox
local submitButton = script.Parent.SubmitButton
-- Step 2: Implement the proximity prompt
local proximityPrompt = script.Parent.ProximityPrompt
proximityPrompt.PromptShown:Connect(function(player)
-- Show the UI when the proximity prompt is activated
script.Parent.Visible = true
end)
proximityPrompt.PromptHidden:Connect(function(player)
-- Hide the UI when the proximity prompt is deactivated
script.Parent.Visible = false
end)
-- Step 3: Play the sound using sound bricks
submitButton.Activated:Connect(function()
local soundID = soundIDTextBox.Text
-- Play the sound using SoundService
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://" .. soundID
sound.Parent = workspace
sound:Play()
end)
Remember to place this script within the UI object and modify it to suit your specific needs. You can also add error handling, validation, and any additional features you require.
I hope this helps you get started with creating the desired system! If you have any further questions or need more assistance, feel free to ask.
Why post ChatGPT Responses if the owner of this topic simply asked for a human-like response. If they would ask ChatGPT for a response, they wouldn’t come here.
If you’re scripting UI for it to play custom sound from SoundID then you need to set the visibility of a UI element before working with sound system, how just @ClientRecon did:
local proximity = [your_proximitypromt] -- ProximityPrompt
local player = game.Players.LocalPlayer -- Player
local gui = player.PlayerGUI.[any_gui] -- There is should be your ScreenGUI
local frame = gui.[your_frame] -- All buttons, textboxes and other frames should be parent to one main frame
frame.Visible = true -- Sets visibility of the frame to true which will be shown in a game
frame.Visible = false -- Opposite of the true which will hide the frame in a game
Now you can detect if ProximityPromt has been triggered and if Close Button has been clicked. Unlike, @ClientRecon made it uncomfortable to set visibility of frame using PromptShown and PromptHidden event. As you’re working with close button and single ProximityPrompt - you need to include them in your code:
local proximity = [your_proximitypromt] -- ProximityPrompt
local player = game.Players.LocalPlayer -- Player
local gui = player.PlayerGUI.[any_gui] -- There is should be your ScreenGUI
local frame = gui.[your_frame] -- All buttons, textboxes and other frames should be parent to one main frame
local closebutton = frame.[close_button] -- Close Button
closebutton.MouseButton1Click:Connect(function()
frame.Visible = false
end)
proximity.Triggered:Connect(function()
frame.Visible = true
end)
The part of the code that is above suppose to run on the client since we don’t want to replicate this change to the server, right?
Now the final step is to get the input of your TextBox which in your GUI includes: input for music id and for volume. Now you need to include these TextBoxes in code and also include the general volume:
local proximity = workspace.ProximityPrompt -- ProximityPrompt
local player = game.Players.LocalPlayer -- Player
local frame = workspace.Frame
local closebutton = workspace.TextButton -- Close Button
local musicidinput = workspace.TextBox
local volumeinput = workspace.TextBox
closebutton.MouseButton1Click:Connect(function()
frame.Visible = false
end)
proximity.Triggered:Connect(function()
frame.Visible = true
end)
local mainvolume = 0
volumeinput.FocusLost:Connect(function(pressed)
if pressed then
print("Enter has been pressed!")
local volume = volumeinput.Text
mainvolume = tonumber(volume)
else
print("Enter has not been pressed...")
end
end)
musicidinput.FocusLost:Connect(function(pressed)
if pressed then
print("Enter has been pressed!")
local id = musicidinput.Text
else
print("Enter has not been pressed...")
end
end)
Now, you just need to replicate sound instance to a server from client but @ClientRecon have already made everything but aware that it would run locally which means every change will be applied only for your client. To replicate change from client to server, you may need to read about RemoteEvent in Roblox Resources.