Sure, here’s the file
Slider thing.rbxl (53.0 KB)
I’m using the version linked the post
https://www.roblox.com/library/6460129603/LayoutUtil-v2
Sure, here’s the file
Slider thing.rbxl (53.0 KB)
I’m using the version linked the post
https://www.roblox.com/library/6460129603/LayoutUtil-v2
Thanks! Will check it out and see if I can find any bugs to why this happens lol
Issue found! Whenever :OverrideValue()
was used, it sets IsHeld
to false. Now, there are two ways you can fix this.
I just remove that function that sets IsHeld to false, this could be bad as if the value is overridden, the slider could just move back into place when the mouse is moved.
You can fix your code, which I’ve figured out why it happens:
:GetPropertyChangedSignal
function, causing a loop.
I’m not exactly sure how you can fix this, but one thing I would do is make a separate function which overrides the value and only call that when needed.
Ah I see, thank you for the quick response, I’ll see how I get it fixed later
Edit
Here’s the solution in case anyone comes across the same issue:
--local IsSliding = false --Nvm just use IsHeld
--My Value, used by the slider, changed. I want to update my slider.
Object:GetPropertyChangedSignal("Volume"):Connect(function()
if Slider.IsHeld == false then --But only if slider isn't being held
Slider:OverrideValue(Object[SliderString])
end
end)
--My Slider changed, update my value.
Slider.Changed:Connect(function(Value)
Object[SliderString] = Value
end)
-- Updates bool to prevent loop
--Slider.Dragged:Connect(function()
-- IsSliding = true
--end)
--Slider.Released:Connect(function()
-- IsSliding = false
--end)
Fyi, you can check Slider.IsHeld
to see if the slider is being held!
Update!
Sorry for taking so long to release this, I was really busy with school! (Aka I’m a lazy idot and need to work more)
Anyway:
Additions
SurfaceGui Support is here!! The way it works is the exact same as creating a normal slider.
The only difference is that the module will instead detect what you are using, whether it be a surface gui or a screen gui, it will adapt accordingly. (Please don’t murder me this code can be neater!)
The module will also perform a raycast when using a surface gui, this is necessary in order to detect where the heck you’re pointing at!
If you want to find out how I did this, look at the :Update
function in lines 224-281 (iirc)
Credit to this post below because otherwise I would have been very stuck lol:
Bug fix!
Changes
A quick little bug fix I made was getting the surface gui to work on all sides, before writing this, it would bug out on any side that wasn’t the front. This was due to how I calculated the top left corner of the side to figure out where the mouse position was (that sounds complicated, trust me it’s not).
(For reference, topLeftCFrame
used to be a different calculation which bugged out)
Anyways, this is now fixed!
PS: Just fixed another bug with surface guis, the module would calculate the mouse offset wrong for the X and Z axis on surfaces other than the front and back, also fixed!
Crazy to see you’re still maintaining since the initial release. This is a very nice utility, and it is something I am definitely going to recommend to my friends in the future. Keep up the good work!
Thank you! If you have any other requests for me to add things/change stuff please let me know haha
Bug fix #2
I seriously need to learn to rigorously test my stuff before releasing it .
Just fixed a bug where the Y axis wasn’t calculated properly on surface guis, this was due to an issue with converting the mouse offset.
Anyways, fixed aswell.
Looks professional and customizable. I will definitely be bookmarking this whenever I find a use case. Thanks for making this.
does the OverrideValue() works if the value is changing like;(TimePosition of playing music)
No problem! Any features or issues you have please let me know
Yes, that’s actually one of the first things I made with it!
i absolutely love this module
but i do wish there was an option to connect a progress bar to the slider
https://gyazo.com/bbf0a1e9bf92f96a76c0d2002e67dc3c
music slider i made (looks like spotify)
Thank you haha, I’m a bit unsure what you mean by connect a progress bar? You could do that with :OverrideValue()
This can cause a C stack overflow, depending on circumstance
Slider.__index = function(object, indexed)
local deprecated = {
{".OnChange", ".Changed", object.Changed} -- This indexes itself infinitely
}
for _, tbl in ipairs(deprecated) do
local deprecatedStr = Sub(tbl[1], 2)
if deprecatedStr == indexed then
warn(Format("%s is deprecated, please use %s instead", tbl[1], tbl[2]))
return tbl[3]
end
end
return Slider[indexed]
end
You need to change that line into this:
{".OnChange", ".Changed", rawget(object, "Changed")}
Hey! Going through the source I noticed that there are a lot of variables for items that are used from 2-8 times in the script. It may not be a major memory issue, but I don’t think there is a need to shorten the libraries.
Oh whoops! Completely forgot that __index
can cause that, will change as soon as I’m home! Thank you