Audio Not Playing

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a gunshot that is Server-Sided so everyone can hear it, not only the local player.

  2. What is the issue? Include screenshots / videos if possible!
    The audio doesn’t play, even though there’s no errors.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looping the sound and playing it when the player joins, still doesn’t work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local remoteEvent = game.ReplicatedStorage.Events.Shoot
local playerEvent = game.ReplicatedStorage.Events.PlayerAdded
local plr = nil
local char = nil

game.Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	for _, v in pairs(character:GetDescendants()) do
		if v:IsA("Sound") then
			if v.Name == "FireSound" then
				v:Destroy()
			end
		end
	end
	fireSound = Instance.new("Sound")
	fireSound.Name = "FireSound"
	fireSound.Volume = game.ReplicatedStorage.Sounds.AK103.Fire.Volume
	fireSound.SoundId = game.ReplicatedStorage.Sounds.AK103.Fire.SoundId
        fireSound.Parent = character.HumanoidRootPart
	plr = player
	char = character
end)

remoteEvent.OnServerEvent:Connect(function()
	fireSound:Play()
end)

The script above is the server script, responsible for creating the sound and playing it

function Shoot()
	for _, v in pairs(framework.viewmodel:GetDescendants()) do
		if v:IsA("ParticleEmitter") or v:IsA("PointLight") then
			v.Enabled = true
		end
	end
	fireAnim:Play()
	framework.module.ammo -= 1
	game.ReplicatedStorage.Events.Shoot:FireServer()

	wait(framework.module.fireRate)
end

The Script above is the client script (only a portion of it) responsible for firing the remote event to the server when the gun shoots

Thanks!

1 Like
fireSound = Instance.new("Sound")
	fireSound.Name = "FireSound"
	fireSound.Volume = game.ReplicatedStorage.Sounds.AK103.Fire.Volume
	fireSound.SoundId = game.ReplicatedStorage.Sounds.AK103.Fire.SoundId
	fireSound.Looped = true
    fireSound.Parent = player.Character

maybe???

I found the solution myself, I put the sound in the HRP (HumanoidRootPart) instead of putting it in the torso, sorry!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.