So i have RemoteEvent called sound in my Replicated Storage with the actual Sound called FireSound I have a script in serverscript called Sound Global that goes like this:
game.ReplicatedStorage.Sound.OnServerEvent:Connect(function(Player) local fireSound = game.ReplicatedStorage.FireSound fireSound:Play() end)
Inside my gun the code goes like this:
script.Parent.Activated:Connect(function() if Ammo>0 and not Reloading then Ammo=Ammo-1 game.ReplicatedStorage.Sound:FireServer() end
you need to put the sound in either the gun tool or workspace, but i recommend the gun tool: then do the following
game.ReplicatedStorage.Sound.OnServerEvent:Connect(function(Player,name) local char = player.Character local tool = char:FindFirstChild(name) local fireSound = tool["name of the sound object"] fireSound:Play() end)
Inside my gun the code goes like this:
script.Parent.Activated:Connect(function() if Ammo>0 and not Reloading then local tool_name = --put here the name of the tool Ammo=Ammo-1 game.ReplicatedStorage.Sound:FireServer(tool_name) end