Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If I change the playback speed of a sound I no longer hear it? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

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 :)

0
You used floating point numbers in your math.random arguments and math.random just calls math.floor on your parameters. hiimgoodpack 2009 — 5y

Answer this question