Change Speed of Animation Using Slider

I’m trying to change the speed of an animation depending on where the slider is. The minimum value of the position scale X is 0, the maximum is 0.8. If the position is around 0, I’d like to change the speed to slow, if it’s around 0.4 I’d like it to be normal, and if it’s around 0.8 I’d like it to be fast. I figured out the changing animation speed part, but I’m not sure how to check where the slider is approximately and then change the speed. Any help?

Here is the script:

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6514593964"
local Anim = Animator:LoadAnimation(Animation)

local slider = script.Parent.Parent.Parent.Parent.Background.SliderObject

script.Parent.MouseButton1Click:Connect(function()
	local MaxSliderX = 0
	local MinSliderX = 0.8
	local SizeX = slider.Position.X.Scale

	Anim:AdjustSpeed(0.5) -- Slower
	-- Do nothing if normal
	Anim:AdjustSpeed(2)-- Faster
	Anim:Play()
	while true do
		if game.Players.LocalPlayer.Character.Humanoid.MoveDirection.Magnitude > 0 then
			Anim:Stop()
		end
		wait(0.5)
	end
end)

Thank you for helping!

@BanTech provided some insight on how you can best approach a slider. I suggest you take a read!

Thanks for the article! I took a look but I think the slider I have is already similar. Right now the slider works it’s just I’m not sure how to check if the position is around a certain area and then change the speed accordingly.