I have a bullet hit sound so when you hit a material different types play different sounds but for some reason if I change the pitch to add variety if I no longer hear the sound.
Hers my code I set playback speed at the bottom
local HitAudioPart = Instance.new("Part") HitAudioPart.Position = HitPosition HitAudioPart.Anchored = true HitAudioPart.CanCollide = false HitAudioPart.Transparency = 1 HitAudioPart.Size = Vector3.new(1, 1, 1) HitAudioPart.Parent = workspace.IgnoreFolder DebrisService:AddItem(HitAudioPart, 25) local ClonedAudio = CurrentWeapon.Handle.HitSound:Clone() ClonedAudio.SoundId = BulletImpactSounds[string.sub(tostring(HitMaterial), 15)] ClonedAudio.Volume = 3 ClonedAudio.Parent = HitAudioPart ClonedAudio:Play() ClonedAudio.PlaybackSpeed = math.random(.75, 1.25)
I am very confused as to why this breaks it. If I comment out the playback speed line it works fine so it has to do with playback speed.
Anyone have any ideas?
-SOLVED- I have since solved this if anyone else has this problem. Its because of math.random for some reason. If I use Random.new:NextNumber() it works fine :)