Trying to get some audio to play when a setting on a module script called "InstantHit" is changed to false. How ever in the main code, the sounds do not play if InstantHit is changed to false instead of true. Code from MAIN script below
if S.InstantHit then -- Tried putting "S.InstantHit == false" still does not play the sound and breaks the gun. local HitObj, HitPos = AdvRayCast(Main.CFrame.p, Direction, S.BulletRange) local HitHumanoid = nil local SoundPart1 = Instance.new("Part") SoundPart1.Transparency = 1 SoundPart1.Anchored = true SoundPart1.CanCollide = false SoundPart1.CFrame = CFrame.new(HitPos) SoundPart1.Parent = game.Workspace local BulletHit = Instance.new("Sound") BulletHit.Pitch = 1 local soundIndex = math.random( 1, #SoundIDs ) BulletHit.SoundId = SoundIDs[soundIndex] BulletHit.Volume = 1.5 BulletHit.Parent = SoundPart1 BulletHit:Play() delay(1 / 20, function() SoundPart1:Destroy()