SliderService - Create easy and functional Sliders!

Well yea they’re really easy to make but it would be a cool little addition that would fit well with this module.

My slider is upside-down ! when silding down, it increases the value, and when sliding up, it decreases the value. here’s my code :

local sliderService = require(game:GetService("ReplicatedStorage").Slider)

local volume_slider = sliderService.new(script.Parent, 
	{
		SliderData = {
			Start=0,
			End=1,
			Increment=0.01,
			DefaultValue = 1
		},
		MoveType = "Instant",
		MoveInfo = nil,
		Axis = "Y"
	}
)

volume_slider.Dragged:Connect(function(value)
	print(value)
end)

volume_slider:Track()

Do you mind sending me a place file? preferably in DM’s
Just the bare minimum so I can see if it’s something with your UI

Hey my slider is also upside down must be something wrong with the module:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Slider = require(ReplicatedStorage:WaitForChild("Slider"))

local holderFrame = script.Parent
local currentCamera = workspace.CurrentCamera

local FOVSlider = Slider.new(holderFrame, {
	SliderData = {Start = 60, End = 110, Increment = 5, DefaultValue = 90},
	MoveInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad),
	Axis = "Y",
	Padding = 5,
	AllowBackgroundClick = true,
})

FOVSlider.Changed:Connect(function(newFov: number)
	workspace.CurrentCamera.FieldOfView = newFov
	script.Parent.Slider.Text = newFov
end)

FOVSlider:Track()

FOVSlider.rbxl (65.8 KB)

My slider isn’t working. I can click the slider bar and it does set the value, but the drag button doesn’t show up. When I looked at it while testing, I noticed the position was {nan, 0},{0.6, 0}. I manually set it and it started working fine, so I think it might do that at setup.

1 Like

you can make a toggle slider like this

local ToggleSlider = Slider.new(holderFrame, {
	SliderData = {Start = 0, End = 1, Increment = 1, DefaultValue = 0},
	MoveInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad),
	Axis = "X",
	AllowBackgroundClick = true,
})

ToggleSlider.Changed:Connect(function(new)
    if new == 1 then
        --change background of the slider to green
    elseif new == 0 then
        --change background of the slider to red
    end
end)

The slider doesn’t work. It moves the slider but it doesn’t fire the Changed event I think.

This is my code:

local MaxPlayerSlider = SliderService.new(StartGameFrame:WaitForChild("Frame"):WaitForChild("ScrollingFrame"):WaitForChild("MaxPlayers"):WaitForChild("SliderFrame"), {
	SliderData = {Start = 2, End = 30, Increment = 1, DefaultValue = 2},
	MoveInfo = nil,
	MoveType = "Instant"
})

MaxPlayerSlider.Changed:Connect(function(newValue)
	print(newValue)
	maxPlayers = newValue
	StartGameFrame.Frame.ScrollingFrame.MaxPlayers.Num.Text = newValue
end)

--coroutine.wrap(function()
--	while task.wait(0.2) do
--		maxPlayers = MaxPlayerSlider:GetValue()
--		StartGameFrame.Frame.ScrollingFrame.MaxPlayers.Num.Text = MaxPlayerSlider:GetValue()
--	end
--end)()

MaxPlayerSlider:Track()

The error is:

1 Like

@Krystaltinan This is still an issue. This resource no longer functions. I would either fix it or make it clear that it’s discontinued.

Mind showing your configuration code?

I doubt it has anything to do with the configuration as I am having this issue as well. It fixes if I resize my window (???). It has something to do with how you’re setting the position of the slider handle.

Will have a look as soon as I can, will report when updated

1 Like

I really like this module! I will definitely use this module for my project :smiley:

for i, v in Sliders do
	local Slider = v.UIToClone:Clone()
	Slider.Name = i
	Slider.Amount.Text = v.SlideInfo.SliderData.DefaultValue
	Slider.Title.Text = v.DisplayName
	
	Slider.Parent = script.Parent.Sliders
	
	local Slide = SliderMod.new(Slider, v.SlideInfo)
	
	Slide.Changed:Connect(function(NewVal)
		Slider.Amount.Text = math.round(NewVal)
	end)
	
	Slide:Track()
end

Sliders is a table of different slider configs, currently I only have one, but I didn’t want to need to hardcode the display method, so don’t worry much about it.

either I’m doing this wrong, or something’s broken, since this ALWAYS errors with the same error of
21:21:47.737 ReplicatedStorage.Modules.SliderService.Utils.Signal:51: invalid argument #1 to 'unpack' (table expected, got nil) - Studio,

I’ve checked and I’ve got every required parameter going in, and in trying to fix it, I have even the non-mandatory parameters in the dictionary, I’ve printed all my inputted values and none of them are nil

Sorry all, have been very busy with Christmas stuff, will check up on those two bugs now!

2 Likes

It seems that something is going wrong with the Changed event and the signal data being corrupted, am going to try fix asap.

1 Like

Oh hi Krypt, remember me from almost 2 years ago now?

I thought the model was complete back then, oh how wrong was I.
Good job with the module bro! :+1:

The model is clearly not perfect right now as people are having the same issue.
ReplicatedStorage.Modules.SliderService.Utils.Signal:51: invalid argument #1 to 'unpack' (table expected, got nil) - Studio

Hey, I was wondering how you would connect some sort of bar to the slider button (im stupid and dont know how to do this :stuck_out_tongue: , sorry for the trouble)

This is wonderful and super useful/easy to setup! Thanks so much!!!

+rep or whatever! :3

The model is clearly not perfect right now as people are having the same issue.
ReplicatedStorage.Modules.SliderService.Utils.Signal:51: invalid argument #1 to 'unpack' (table expected, got nil) - Studio

This is an issue with the signal module and with the connections. (or atleast that’s what I think from the debugging).

I’m currently not home but I’ve been looking into why it only happens for one signal and not the others.

3 Likes