Make it so that the pitch changed with each click?

Hello, I’m trying to make it so that the pitch of the sound changes randomly each time you click the tool. This is what I have so far.

local sound = script.Parent.Handle.Fire

script.Parent.Activated:Connect(function()
	sound.Pitch = math.random(1, 6)
end)

I would’ve thought it would work but I guess not. If anyone knows how to fix it please let me know.

1 Like

I’m pretty sure ‘Pitch’ is deprecated, use PitchShiftSoundEffect instead.

Hi, the pitch changes but, it only changes once. It doesnt change with each click like I thought I put into the script.

1 Like

Try this instead:

local sound = script.Parent.Handle.Fire
local rand = Random.new()

script.Parent.Activated:Connect(function()
	sound.Pitch = rand:NextInteger(1, 6)
	warn(sound.Pitch)
end)