Guys I wanted to make a mtf radio and when the player clicks on a button it will produce a local sound and everyone close to it will hear it I've tried several ways but I can't can someone explain to me what I can use for this? like as soon as the player clicks a button in the gui this sound will play at the location and everyone close to it will hear it
can you explain to me a way for me to create my mtf radio?
1 answer
If you haven't heard of RemoteEvents or don't know how to use them, you'll need to learn them first before being able to do this. You can find a few tutorials on YouTube or any other source. If you have learned them already though, good for you! It'll make this much easier.
If you didn't know, Sounds can be placed/parented inside Parts to create a proximity effect. The closer you get to the part, the louder the sound gets.
To start, let's connect an OnServerEvent event and give it a function.
-- // SERVER
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplictedStorage.PlaySound -- // Change this to your RemoteEvent name
RemoteEvent.OnServerEvent:Connect(function(Player)
local Sound = Instance.new("Sound")
local SoundId = "rbxassetid://12345" -- // Change 12345 to your SoundId
Sound.Parent = Player.Character.HumanoidRootPart -- // Change to which part the sound should be played in
Sound.SoundId = SoundId
Sound:Play()
game.Debris:AddItem(Sound, Sound.TimeLength) -- // Clear the sound after [Sound Length] seconds
end)
Now for the GUI button!
-- // CLIENT
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplictedStorage.PlaySound -- // Change this to your RemoteEvent name
local Button = ButtonPath -- // Change this to the path of the GUI button
Button.MouseButton1Down:Connect(function()
RemoteEvent:FireServer()
end)
That should be it! The sound should play when you click on the button now. Hope this helped you, if there are any issues or questions feel free to ask!
This discussion is preserved as it was. New answers, comments, and votes are closed.
