I want to make a scrolling frame but I need to disable scrolling and add two buttons, an up and down button, and when you hold on the up button the scrolling frame scrolls up and the same for down.
any way that I can do that? Also when I hold the button it doesn’t work I used script.Parent.MouseButton1Down
Galactiq
(Matthew)
November 15, 2020, 5:21pm
#2
I’m pretty sure you can use the CanvasPosition
property of ScrollingFrame instances to accomplish said task. Each time a player clicks the up or down button, tween or just change the CanvasPosition
property accordingly. Have a good day.
1 Like
But how do I make it so that you can hold the buttons and it will keep on scrolling instead of having to click alot
Galactiq
(Matthew)
November 15, 2020, 5:42pm
#4
local Frame = script.Parent.ScrollingFrame -- Change to frame.
local UpButton = script.Parent.Up -- Change to the correct pathway in your game.
local DownButton = script.Parent.Down -- Again, change pathway.
local HoldingUp = false
local HoldingDown = false
UpButton.MouseButton1Down:Connect(function()
HoldingUp = true
HoldingDown = false
end)
UpButton.MouseButton1Up:Connect(function()
HoldingUp = false
HoldingDown = false
end)
DownButton.MouseButton1Down:Connect(function()
HoldingDown = true
HoldingUp = false
end)
DownButton.MouseButton1Up:Connect(function()
HoldingDown = false
HoldingUp = false
end)
coroutine.wrap(function()
while wait() do
local inc = 0
if HoldingUp then
inc = -1
elseif HoldingDown then
inc = 1
end
Frame.CanvasPosition = math.clamp(Frame.CanvasPosition + inc,0,Frame.AbsoluteWindowSize.Y)
end
end)()
I haven’t tested this myself, so it might have problems. But this is just what I thought from the top of my head. Hopefully it helps. Enjoy!
no, for some reason it just doesn’t scroll
Galactiq
(Matthew)
November 15, 2020, 5:47pm
#6
Did you define the variables? 30char
Yes I did define but for some reason nothing happens when I click and hold the buttons
Nope, no errors for some reason. Only the errors from my self-made plugins…
local UpButton = script.Parent.Up.TextButton
local DownButton = script.Parent.Down.TextButton
local HoldingUp = false
local HoldingDown = false
UpButton.MouseButton1Down:Connect(function()
HoldingUp = true
HoldingDown = false
end)
UpButton.MouseButton1Up:Connect(function()
HoldingUp = false
HoldingDown = false
end)
DownButton.MouseButton1Down:Connect(function()
HoldingDown = true
HoldingUp = false
end)
DownButton.MouseButton1Up:Connect(function()
HoldingDown = false
HoldingUp = false
end)
coroutine.wrap(function()
while wait() do
local inc = 0
if HoldingUp then
inc = -5
elseif HoldingDown then
inc = 5
end
Frame.CanvasPosition = math.clamp(Frame.CanvasPosition + inc,0,Frame.AbsoluteWindowSize.Y)
end
end)```
Galactiq
(Matthew)
November 15, 2020, 5:52pm
#10
Change this line to:
Frame.CanvasPosition = math.clamp(Frame.CanvasPosition + inc,0,Frame.AbsoluteSize.Y)
I made a mistake (I think).
Here is some footage of the “new” line but still doesn’t work (my cursor became invisible because I was recording the footage so I accidently keep clicking the post button…)
https://i.gyazo.com/d30fedd79c433740345d2554b038ea47.mp4
Galactiq
(Matthew)
November 15, 2020, 5:58pm
#12
So I think you can’t scroll because the CanvasSize is 0 maybe???
Wait I just changed canvas pos to 0,0
Galactiq
(Matthew)
November 15, 2020, 6:02pm
#14
OH! It’s a UDim value. I am so sorry for the confusion.
Frame.CanvasPosition = UDim.new(0,math.clamp(Frame.CanvasPosition + inc,0,Frame.AbsoluteSize.Y))
Galactiq
(Matthew)
November 15, 2020, 6:05pm
#16
Add me as a friend. I am gonna figure this out.
Lol, I just realized you were playing my game. I added you as a friend.