Pitch Slider using the new UiDragDetectors?

I sucessfully made a non-functional slider with UiDragDetector slider, I have been here for hours trying to figure out how I can map it to a PitchShiftSoundEffect’s Octave

  1. Tried using mathematical formulas
    1.1. Nope pitch is stuck at 0.5
  2. Tried using an if of pos > 45 etc…
    2.1. Same issue

I can’t find a way to convert this slider’s frame’s Y position to the Octave/pitch

For context the bottom-most it can go is Y95, top-most Y0 and for the center which is what I want Pitch = 1 to be is Y30

Edit: I ensured paths are all correct, they really are.

2 Likes

Can’t you just divide the Current Y position of the slider by 30, and then set that to be the pitch?

1 Like

Ratio equation is:

(yPosition - minSliderY) / (maxSliderY - minSliderY)

For your case, something along the lines of:

local maxSliderY = 95;
local minSliderY = 0;

local centrePointY = 30;

local function GetPitch(YPosition)
	return 1 + ((YPosition - centrePointY) / (maxSliderY - minSliderY));
end

@PiercedMissile’s idea actually probably better as I assume you’re looking for fixed-values.

1 Like

Neither this or @PiercedMissile 's solution work unfortunately.
It’s always stuck at once pitch level (which is not 1) and sliding doesn’t change anything

Edit: Possibly it’s my loop? What should I put this into, I tried while true loops and UiDragDetector.Changed:Connect but they output the thing I just explained

1 Like

UiDragDetector:GetPropertyChangedSignal(“Position”):Connect()

1 Like
script.Parent:GetPropertyChangedSignal("Position"):Connect(function ()
	game.Workspace.Part.Mixer.MusicPlayer.ImageButton.Script.Song.PitchShiftSoundEffect.Octave = script.Parent.Position.Y.Offset / 30
end)

It still manages to not work

1 Like

I haven’t used UiDragDetectors before, but checking for the Position property raises alarm bells because that’s usually used for the literal position of the UI, which shouldn’t be moving much.

I think you should take a look at these events instead:

1 Like

Neither of these work either for some reason

1 Like

Could you also send the explorer window?

Screenshot 2024-11-17 213023
Screenshot 2024-11-17 215402

were you referencing the drag detector for those events?

Yes I was referencing it not the frame

have you tried using the old Frame MouseEvents?

(Using :MouseEnter) The music pitch is normal, you enter the mouse and the pitch is set to the correctly calculated result, but then if you slide the thing it doesn’t do anything

Things I tested:

  1. No conflicting scripts
  2. While true loops don’t work either

Edit: None of the MouseEvents work

By the way, it’s a SurfaceGui if that helps

Song playing script:

local Playing = false
_G.Song = script.Song
local lastPosition = 0
_G.SongId = "rbxassetid://"

if _G.Song then
	_G.Song.SoundId = _G.SongId
	script.Parent.MouseButton1Click:Connect(function()
		if Playing then
			script.Parent.Image = "rbxassetid://"
			lastPosition = _G.Song.TimePosition
			_G.Song:Pause()
		else
			script.Parent.Image = "rbxassetid://"
			_G.Song.TimePosition = lastPosition
			_G.Song:Play()
		end
		Playing = not Playing
	end)
else
	warn("Song object not found!")
end

Pitch slider script, now the looping works which is good news

while task.wait(0.01) do
	game.Workspace.Part.Mixer.MusicPlayer.ImageButton.Script.Song.PlaybackSpeed = (script.Parent.Position.Y.Offset  - 95) / (0 - 95) 
end

I’m closing this for a new issue, the formula works