Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can you explain to me a way for me to create my mtf radio?

Asked by 2 years ago

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

1 answer

Log in to vote
0
Answered by
Neatwyy 123
2 years ago
Edited 2 years ago

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!

Ad

Answer this question