Slider object for Gui's

Currently Roblox does not offer a proper ‘Slider’ object for Gui’s. The closest we have to a slider is a ScrollingFrame, but you’re often better off programming your own slider if you don’t want your slider to be attached to a frame; getting the position of the scrollbar itself is a bit awkward because you have to read the CanvasPosition property and using a Scrolling Frame is just a hacky substitute in general. Programming your own slider isn’t a good solution either though. Especially the boundaries can be a real pain to program. I therefore request a new Gui element: a Slider.

A slider has many use cases. If you want to make your own music player you might want to use a slider to change the volume of a song. A slider can also have multiple uses in character creators. You can use a slider to rotate the character model you’re making or you can use it to quickly change the color of your character’s hair.

I think a ‘Slider’ object would be a great addition for beginning developer as it allows them to be more creative with UI development, but a slider would also prevent a lot of headaches among the more experienced developers; although it’s a simple feature on paper, it’s not something you want to make yourself.

26 Likes

As much as I like the idea I doubt it will be implemented because it’s not too difficult to create your own. IIRC the last time I made one it was an ImageButton and I detected when the player clicked and held their mouse and how far they moved it in either the x or y direction depending on which way the slider went.

This isn’t too hard to create yourself, and I doubt it would be used very often.

This is also the case with ScrollingFrames.

If we go by the argument that it’s easy to create your own, then we might as well not have had TextButtons in the first place; you can just use a TextLabel instead and use a MouseEnter and MouseLeave event to check if the mouse is within the box and then use UserInputService to check when you click. Easy right?

In all seriousness though, given that we already have a ScrollingFrame this feature shouldn’t be hard to implement. Most of the code has already been written. Sliders can still be really useful for the examples I mentioned above. Most RPGs on Roblox have some kind of character creator system so they could benefit from this. Other games can also use this to easily change music volume instead of a toggle which either enables or disables music. Roblox is also a platform for all ages. More than half the people on this forum would be able to program something like this, yes, but there are so many beginners who could really use simple features like these. Just because you can make it yourself doesn’t mean it shouldn’t be added. And the fact that we already have ScrollingFrames makes it even more odd that we don’t just have a regular Slider object yet.

12 Likes

I’m pretty sure there’s a module script out there which might be sponsored by roblox and provides a function for creating a slider object as well as some other objects (drop down lists, etc.).

I think for the time being, I would prefer they stick to that and don’t add API bloat. We have the basic building blocks to create all GUI elements. I understand the draw for a slider object, but I think having a built in type for it might be overkill.

Also, if anyone knows of the module script I’m talking about, do me a favor and link it. I couldn’t tell you anything about it except that it has the GUI elements that you see on roblox’s GUIs. :stuck_out_tongue:

1 Like

Support–not just because it’s a basic UI element with hundreds of common use cases, but because I would expect out-of-the-box support for this out of any other development environment.

You’re talking about RbxGui. They stopped maintaining that a few years ago.

I wouldn’t consider a basic UI control API bloat. Android Studio supports all of this

5 Likes

In practise this means “someone makes a module for it, then you use that”.
Someone just has to actually write such a module, and it needs visibility.

Anaminus has a slider in his set of useful GUI control elements.

1 Like

The biggest problem with these more specific UI elements is style. By creating a default UI element with higher-level functionality, you get locked into a style that may not be fitting for your game. For instance, is the slider animated? Are there margins/padding between parts of it? Labels? Just look at the amount of configuration available on Java’s JSlider object.

I personally think that items of higher functionality should be designed by the user.

1 Like

Yeah there is. I use it in one of my old games. I don’t have time to dissect the code though, so here’s how I used it if you want to decipher it :stuck_out_tongue:

function LoadSliders()
	local RbxGui = assert(LoadLibrary('RbxGui'))
	local sizeFactor = script.Parent.AbsoluteSize.X * 0.2
	
	sliderR, rValue = RbxGui.CreateSlider(255,1,UDim2.new(0,0,0.5,0))
	sliderR.Parent = script.Parent.Color.R
	sliderR.Bar.Size = UDim2.new(1,0,0,5)
	
	sliderG, gValue = RbxGui.CreateSlider(255,1,UDim2.new(0,0,0.5,0))
	sliderG.Parent = script.Parent.Color.G
	sliderG.Bar.Size = UDim2.new(1,0,0,5)
	
	sliderB, bValue = RbxGui.CreateSlider(255,1,UDim2.new(0,0,0.5,0))
	sliderB.Parent = script.Parent.Color.B
	sliderB.Bar.Size = UDim2.new(1,0,0,5)
	
	changed = function()
		script.Parent.Color.Preview.BackgroundColor3 = Color3.new(rValue.Value/255,gValue.Value/255,bValue.Value/255)
	end
	sliderR.Bar.Slider.Changed:connect(changed)
	sliderG.Bar.Slider.Changed:connect(changed)
	sliderB.Bar.Slider.Changed:connect(changed)
end

LoadSliders()

The code just changed a gui to use the RGB value given by the sliders.

1 Like

I have a lot of use for this but don’t want to make a thread for it, so here’s a bump. The make your own approach isn’t nearly as intuitive as being able to just place a bar in and have properties to change the slider image and having an easy number to reference in scripts. Sure I could make my own, but what about newer users that don’t have the scripting experience to be able to make one of these. With sound being more and more important in game development, being able to easily place sliders so users can change level of sound with such bars would be nice.

7 Likes