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
Tried using mathematical formulas
1.1. Nope pitch is stuck at 0.5
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.
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.
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
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:
(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
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