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

I'm setting the playback speed for a sound, why can't I hear a difference?

Asked by
JPT79 92
4 years ago

I've made a pickup script and I wanted to add a sound effect that varies in pitch, I've setup the script so the sound's PlaybackSpeed is randomized, then print the PlaybackSpeed afterwards so I can ensure it's working. The issue is, while the printed text shows that the PlaybackSpeed was indeed randomized you cannot hear a difference at all.

Here is the script, it's in a normal script

math.randomseed(tick())
local crate = script.Parent
local invCrate = game.ReplicatedStorage["Light Crate"]
local sound = script.Parent.Pop -- Pickup sound

script.Parent.ClickDetector.MouseClick:connect(function(player)
    print(player, " picked up ", script.Parent)
    -- Sound stuff is here
    sound.PlaybackSpeed = math.random() + 0.1
    print(sound.PlaybackSpeed)
    -- This is just for picking up the crate
    local newPart = invCrate:Clone()
    newPart.Parent = player.Backpack
    crate:Destroy()
end)

and the sound part has PlayOnRemove set so it'll play when the crate is picked up

0
Also I've currently got it set to a speed between 0.1 & 1, but is there a way I could do a speed between 0.1 & 2 while still being able to get decimal numbers? JPT79 92 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Instead of enable PlayOnRemove and then remove it, you can :Play the sound then delete it Also remember to set MaxActivationDistance of clickdetector to 0 for prevent Spamming

Hope that helped

Ad

Answer this question