[V2.0.7] Slider Class - Create Sliders With Ease!

Replace if condition == false then return warn() end with assert(condition, message)

Assert stops the code from running and I personally don’t like using it, I just use warning to tell the developer he did something wrong and let everything running as normal.

1 Like

remove return in that line, warn() doesn’t even return anything, just puts a warning in the terminal

It’s purpose is to stop the code and since warn() returns nil I place warn() after return so it doesn’t return unneeded value and, in the same time, stop the code from running.

Thanks for all your recommendations!

1 Like

I got this error when I was about to add it :confused:

ReplicatedStorage.Slider:143: invalid argument #3 to 'clamp' (max must be greater than or equal to min)

May you send the code to me? Let’s continue this in PMs so we don’t fill the post.

An issue where slider:SetValue() calculates values incorrectly has been fixed!

Update V1.2.2

:bug: bug fixes :bug:

  • slider:GetValue() problems with negative values
  • slider:SetValue() problems

:new: News :new:

  • Added a default value property
  • Added a slider:Reset() function

I i’ve made a script to test this module and this doesn’t work, any help? here is the script:

local SliderModule = require(game.ReplicatedStorage.MODULE.Slider)
local slider = SliderModule.new(script.Parent.Test.Frame,
	
	{step: 0.01, values = {min = 0, max = 130},
	defaultValue = 0,
	axis = "Y"},
	{waypoints = {10: "test", 20: "test2",}
	})

game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode ~= Enum.KeyCode.E then return end

	slider:Reset()
end)

The problem is in waypoints, they aren’t created like that, let’s further discus this in PMs.

Does this have Xbox Support? Sliderservice doesn’t support this and I had to hackily implement it.

I’m a PlayStation person so I can’t test it, if you would like, you can help me test it or give me the code u already have and I’ll implement (and maybe make it better?).

Here is the code i used with slider service. I had to use a lower increment value because it would for some reason get stuck.

game:GetService("UserInputService").InputBegan:Connect(function(input, gpe)
	if gpe and input.KeyCode == Enum.KeyCode.ButtonA then
		if GuiService.SelectedObject.Name == "Slider" then
			GuiService:AddSelectionParent("SelectedSlider", GuiService.SelectedObject)
			print("SetSlider")
			SelectedSlider = GuiService.SelectedObject
		end
	end
end)

game:GetService("RunService").Heartbeat:Connect(function(dt)
	local input = game:GetService("UserInputService"):GetGamepadState(Enum.UserInputType.Gamepad1)[17]
	if input.Position.X >= .2 and SelectedSlider then
		Sliders[SelectedSlider.Parent.Name]:OverrideValue(Sliders[SelectedSlider.Parent.Name]:GetValue() + 1)
	end
	
	if input.Position.X <= -.2 and SelectedSlider then
		Sliders[SelectedSlider.Parent.Name]:OverrideValue(Sliders[SelectedSlider.Parent.Name]:GetValue() - .9)
	end
	
	if input.Position.Y >= .5 or input.Position.Y <= -.5 then -- Check if the players is trying to move
		GuiService:RemoveSelectionGroup("SelectedSlider")
		SelectedSlider = nil
	end
end)
1 Like

:tada: Update V2 :tada:

:new: News :new:

  • Xbox support! Big thanks to @MaloniPepperoni for his massive contribution towards this update, it wouldn’t have been possible without him!
  • Added a xboxStep property for convenience
2 Likes

Update V2.0.1

:new: News :new:

  • Added more checks to avoid errors
  • worked more on slider:SetValue(), it’s now better than ever!

Small update, cant really call this an update but ya, I just fixed some mistakes in the OP.

The place file provided in the post has been removed, the example is now included inside the module (folder called “examples”), the video is yet to be updated .-.

If you have made an interesting example and would like to share it, fell free to PM me!

An issue has been found and fixed where tons of errors get thrown when the player dies.

Issue, you made a showcase in youtube and you still kept this

1 Like

No, I still didn’t update the video (it’s the exact same), that’s why I didn’t update the text lol.

1 Like