I just implemented this into my game and a few players are complaining they can’t scroll?
I’m sorry to hear that!
Without more info, I can’t really help you?
My guess is that you’ve hit the ContextActionService sinking issue from earlier in this thread:
To avoid this, you’d want to replace the CAS binding with a UserInputService binding that ignores GameProcessed. Note that this means input will not be sunk, and scrolling might affect the camera.
Steps to change from CAS to UIS
- Remove lines 57-71:
CAS:BindActionAtPriority("SmoothScroll", function(Name,State,Input)
if DraggingBar then return Enum.ContextActionResult.Pass end
local Processed = false
for Frame, Info in pairs(Objects) do
if Info.Hovering and Info.Visibility.Visible == true then
Processed = true
Info.Velocity = Info.Velocity - (Info.Sens * Input.Position.Z * (Info.Inverted and -1 or 1))
end
end
return Processed and Enum.ContextActionResult.Sink or Enum.ContextActionResult.Pass
end, false, 8000, Enum.UserInputType.MouseWheel)
- In that spot (from line 57) add the following:
UIS.InputChanged:Connect(function(Input, GP)
if --[[not GP and]] Input.UserInputType == Enum.UserInputType.MouseWheel and not DraggingBar then
for Frame, Info in pairs(Objects) do
if Info.Hovering and Info.Visibility.Visible == true then
Info.Velocity = Info.Velocity - (Info.Sens * Input.Position.Z * (Info.Inverted and -1 or 1))
end
end
end
end)
Yeah I don’t want it to affect the camera
I tried to use it on a scrolling frame with buttons and It didn’t work so I had to disable it for that specific scrolling frame.
The smooth scrolling for the other scrolling frames work fine for me, but a few players sometimes aren’t able to scroll for some reason??
This is awesome! I’ve been using this in all of my ScrollingFrames, it is really smooth.
I’m not sure why but I seem to be receiving an “invalid frame to smooth” when the frame I’m trying to do is a ScrollingFrame?
Oh nice! I’ve used this quite a bit now and it’s pretty good.
Thank you for making this
Roblox has recently released an API for trackpad gestures. As seen previously in this thread, trackpad users can only scroll via the drag bar with this module’s current state. I am working on adding proper trackpad support, and will then update this thread and the model.
I have a functioning prototype.
However, it falls into the problem of CAS vs. UIS that has been discussed throughout this thread. Because the API is currently UIS-only, there is no way for me to sink the input.
Because of this, this feature may have to wait until Roblox adds trackpad support into the CAS API as well. I have asked them about this, so we shall see.
The module is finally completely functional!
Everyone should go replace the module with this new version if they’ve been using it.
TL;DR:
- Trackpad support
- Fixed issues with not scrolling in some cases
- Fixed issues with affecting camera when scrolling a frame
Everyone make sure to thank @colbert2677 for he helped me test trackpad support and he solved the UIS/CAS issue.
Previous issues
If you remember earlier in the thread, we discussed these.
If the module uses UIS to scroll, the the scrolling input does not get sunk and will move the camera+any other wheel/pan events you’ve connected.
If the module uses CAS to scroll, we can sink the input just fine, but the input doesn’t fire at all when the mouse is over an object inside the frame that can be clicked. (TextBox,ImageButton, etc)
Example of this issue from earlier in the thread
@colbert2677 discovered that the .Active
property fixes the CAS issue, making it the perfect solution. Additionally, the trackpad is an exception to the UIS issue, because the new default camera script uses it too, and only goes if GP is false. The old camera script was CAS-based, so you needed the input sink for it to work. Because the new one is UIS (for trackpads, at least) we can use UIS in this case.
Current behavior
This module now behaves exactly as the default scrolling, but smoothed. It is finally exactly what I’ve been trying to achieve this whole time.
When scrolling, the camera doesn’t get affected. Perfect. When there are GuiButtons in the frame, it still scrolls properly, including sinking the input. We did it!
When you call .Enable()
on a frame, it will disable .Active
on all the frame’s descendants (and future descendants), and store what the property was. When you call .Disable()
on the frame, it’ll return all the descendants to their original .Active
property. This ensures that CAS behaves properly, and that disabling smoothing will fully return to the original state.
Module:
I’m linking it again so you won’t have to scroll all the way back up.
The sensitivity for trackpads appears to be insane in your Lua Learning game, and frames will scroll a ridiculous amount from a tiny trackpad movement. I am using a trackpad on a MacOS if that’s important. I haven’t yet tried Mac trackpad functionality on a scrolling frame using your module.
Edit: I think this is a bug with your game. The module works fine with my trackpad
That’s really weird.
And annoying, since I don’t have a trackpad to test with.
Can you DM me more details? Which frame, etc.
Important update!
I discovered some very bad behavior: when hovering over two ScrollingFrames, both would scroll! This is obviously not ideal, as only the top should scroll.
I started doing a bunch of frustrating ancestry ZIndex tree building and sorting to figure out which is above the other.
Then I found PlayerGui:GetGuiObjectsAtPosition(Mouse.X, Mouse.Y)
. (Wiki)
This function automatically has them sorted, with the top GUI being the first in the array.
Bonus: It’s at mouse position, so I also got to remove all my hovering tracker code since anything in the array is guaranteed to be under the mouse!
Old Behavior:
(Watch the frame in the background)
New Behavior:
Module:
(Also, updated OP with example usage on how to automatically smooth every frame with exception support)
Update:
Improved drag bar behavior, and added support for multi-axis frames!
Old behavior:
Drag bar jumps to mouse pos, determines canvas position from mouse percent in position, only X or Y bar
(Note how the mouse “slides” along the bar)
New behavior:
Determines canvas position from mouse delta, allows bar for both directions (but MouseWheel is only for Y in that case
Module:
https://www.roblox.com/library/3507192220/SmoothScroll-Module
Update:
Added support for ScrollingFrames inside folders!
Also, re-optimized for the new Lua VM!
I forgot that people use folders in their GUIs, so this module would just assume that .Parent
was a GuiBase2d object. It now properly utilizes :FindFirstAncestorWhichIsA()
in order to handle these cases.
However, the drag bar behaves differently on folder-nested frames. I cannot figure out why, since they run the same code. It still works, but it acts… slippery? It doesn’t stick to the mouse properly. I’ll probably facepalm tomorrow and fix it.
Module:
https://www.roblox.com/library/3507192220/SmoothScroll-Module
Update:
Fixed 2 pretty important bugs!
-
I think Roblox might have changed the
.Active
property behavior on Frames because things stopped working for a few people. Fixed it now! -
If you called
.Disable()
, it didn’t:Destroy()
the scrollbar buttons, leaking Instances. Fixed this too!
(Note that you shouldn’t ever really be calling Disable anyway since it automatically disables upon frame deletion, and toggling back and forth during the game is bad practice and wastes resources)
Module:
https://www.roblox.com/library/3507192220/SmoothScroll-Module
For some reason or another, this seems to cause the camera to zoom again; This used to be fixed, correct?
Wait, really? Ugh. I’ll look into it.
yeah, no clue why either. It started happening to vanilla scrollingframes too so
This module is no longer needed.
In Update 421, Roblox added smooth scrolling to ScrollingFrames.
We had a good long run here, and I know this module helped a lot of people while it was around. I hope you all benefited from it, and I’m glad to see Roblox improving the platform so modules like these are unnecessary!
I’m certain that one day, Roblox will make this behavior the default. Until that day, this is what I’ll be using!
^ Just saying, I called it.
Sorry Boatbomber, i know that you put many efforts in this module and yet …, R.I.P SmoothScroll Module
After 1 month.
IT’s still pending…
How long does it take to release it from pending?