Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to play sounds at a point?

I am making a roblox gun and I want to make the gun shot play from the handle / gun so all players can hear when the gun is shot but I am unsure of how to do it. Currently the gunshot sound is only heard for the player firing but how would I do it so its heard from the gun instead so all players can hear it? Here is my current script that only works for the Local Player.

				ReloadSound = Instance.new("Sound", GunGUILocation)
				ReloadSound.SoundId = "rbxassetid://2773470737"
				ReloadSound.PlayOnRemove = true
				ReloadSound:Play()
				ReloadSound:Destroy()

Also GUNGuiLocation = to the player gui.

3 comments

0

this is a local script correct?

0

For the sound part, you'll need to put that in a server script so everyone can hear it. And you need to make sure the sound is inserted to the handle (assuming it's a part) so it can be coming from there.

0

Its a localscript

1 answer

✓ Accepted answer

This is in a LocalScript, that's why its only playing for the client. Assuming there's more in this script that needs to in a LocalScript then you can use RemoteEvents. Basically it allows the client and server to communicate.

Have this code in a server script and have it activate when a RemoteEvent is triggered.

local function Reload()
	ReloadSound = Instance.new("Sound", GunGUILocation)
	ReloadSound.SoundId = "rbxassetid://2773470737"
	ReloadSound.PlayOnRemove = true
	ReloadSound:Play()
	ReloadSound:Destroy()
end

RemoteEvent.OnServerEvent:Connect(Reload)

Replace RemoteEvent with your RemoteEvent

And trigger the RemoteEvent with a local script

RemoteEvent:FireServer()

Replace RemoteEvent with your RemoteEvent

This discussion is preserved as it was. New answers, comments, and votes are closed.