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

How can script buttons (such as voice lines) other players nearby can hear them as well?

Asked by 5 years ago

I'm new to scripting. I have a functioning GUI with all the sounds working perfectly when the buttons are clicked, but only the player can hear the sounds, not other players near them. I'm beginning to understand maybe it's because I'm using LocalScript? I tried using switching to just Script but then the sound doesn't play at all. Do the sounds need to be in the Workspace and the script inside of the starter GUI needs to reference where the sound is? I don't really undstand how to do that either. Hear is the script im using now:

script.Parent.MouseButton1Click:Connect(function() script.Parent.Love.Playing = true end)

And this is the setup: Starter GUI>GUI>Frame>TextButton>LocalScript & Sound

0
"Love" is the is the name of the sound btw. FortunateFeline 2 — 5y
0
To accomplish this you'd need a remote Event. You said you are new to scripting so I will refer you to a wiki page so you can learn about RemoteEvents if you haven't used them yet. RemoteEvents are pretty important in developing games as they are used to send information from a player's Client to the Server. https://developer.roblox.com/articles/Remote-Functions-and-Events Avi_i 2 — 5y
0
Avi_i thank you for your help I will try to learn more about RemoteEvents :) FortunateFeline 2 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Move the sound to a folder in Workspace. Have the localscript in the StarterGui. Have a script in Workspace or ServerScriptService. Have a RemoteEvent in ReplicatedStorage

Have this in the local script

event = game.ReplicatedStorage["Remote Event Name"]
--Put it inside the button btw
script.Parent.MouseButton1Click:Connect(function(Fire)
event:FireServer("Play", game.Players.LocalPlayer.Character.Head.SoundNameHere) -- Here
wait()
end)

Ok now put this inside the script

event = game.ReplicatedStorage["Remote Event Name"]
event.OnServerEvent:Connect(function(state, sound)
if state == "Play" then
wait()
sound:Play()
end
end)

Tell me if this worked for you or if it didn't.

Edit: I've edited the local script above. Just change the SoundNameHere and put the sound inside the head with this handy script (Put it in Workspace and put the sound in Workspace)

game.Players.PlayerAdded:Connect(Function(plr)
local sound = game.Workspace["Your Sound Name Here"]
wait(2) -- lower or increase this if you get an error
sound.Parent = game.Workspace[plr.Name].Head
end)
0
Or if you want the sound to come out of the player move it to the player's head and detect it there. develop_d 53 — 5y
0
Thank you for taking the time to answer my question so thoroughly I really appreciate your help! I'm going to try this now I will get back to you shortly! FortunateFeline 2 — 5y
0
develop_d could you tell me how to make it come out of the players head? Like what do I move to the head, which script/sound? FortunateFeline 2 — 5y
0
FortunateFeline I have edited the scripts and made you a new one to move the sound to the head. Tell me if it works. develop_d 53 — 5y
View all comments (2 more)
0
i tried both ways and it didnt work for me :( im not sure if it has anything to do with the fact i have multiple sound clips or what is happening. The error kept telling me the sound name was not a valid part. I appreciate you trying to help me though, thank you. FortunateFeline 2 — 5y
0
Are you sure the sound in workspace is a sound instance? develop_d 53 — 5y
Ad

Answer this question