diff --git a/Content.Client/Instruments/InstrumentMenu.xaml.cs b/Content.Client/Instruments/InstrumentMenu.xaml.cs index 2081b44ef0..6dac2cdbce 100644 --- a/Content.Client/Instruments/InstrumentMenu.xaml.cs +++ b/Content.Client/Instruments/InstrumentMenu.xaml.cs @@ -128,13 +128,15 @@ namespace Content.Client.Instruments private bool PlayCheck() { + var instrumentEnt = _owner.Instrument?.Owner; var instrument = _owner.Instrument; - if (instrument == null || - !instrument.Owner.TryGetContainerMan(out var conMan)) - { + // If either the entity or component are null, return. + if (instrumentEnt == null || instrument == null) return false; - } + + // If we're a handheld instrument, we might be in a container. Get it just in case. + instrumentEnt.TryGetContainerMan(out var conMan); var localPlayer = IoCManager.Resolve().LocalPlayer; @@ -142,9 +144,8 @@ namespace Content.Client.Instruments if (localPlayer?.ControlledEntity == null) return false; // If the instrument is handheld and we're not holding it, we return. - if (instrument.Handheld && (conMan.Owner != localPlayer.ControlledEntity)) return false; - - var instrumentEnt = instrument.Owner; + if ((instrument.Handheld && (conMan == null + || conMan.Owner != localPlayer.ControlledEntity))) return false; // We check that we're in range unobstructed just in case. return localPlayer.InRangeUnobstructed(instrumentEnt, diff --git a/Resources/Changelog/Parts/instruments.yml b/Resources/Changelog/Parts/instruments.yml new file mode 100644 index 0000000000..664c3debaa --- /dev/null +++ b/Resources/Changelog/Parts/instruments.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix + message: Fixes structure instruments (like the piano) not playing at all.