Scroll bar canvas position not changing

I’m trying to change the canvas scrolling frame to (0,0) when I scroll up or down. But the scrolling frame position doesnt change when I scroll up or down

1 Like

What property of the scrolling frame are you trying to change to (0,0)?

I’m trying to change the canvas position of the scroll bar

Can you show the script your using? Also it may not scroll at all if the canvas size isn’t larger than the parent element.

Ye sure

Local scrollframecanvasposition = script.
Parent.parent.canvasposition

Local button = script.parent

Button. Activated:Connect(function()

Scrollframecanvasposition = vector2.new(0,0)

End)

Is the canvas larger than the parent element?

Also your variable names aren’t the same: The “S” is capitalized in the function.

Local scrollframecanvasposition = script.
Parent.parent.canvasposition

Local button = script.parent

Button. Activated:Connect(function()

Scrollframecanvasposition = vector2.new(0,0)

End)

This is how its laid out:

Scrollingframe - inside the screen gui
Button - inside the scrolling frame
Local Script - inside the button

The scrolling frame is the same size as the parent

Some of the variables weren’t correct. I adjusted them.

local scrollframecanvasposition = script.Parent.Parent
local button = script.Parent

button.Activated:Connect(function()
	scrollframecanvas.CanvasPosition = vector2.new(0,0)
end)
1 Like

Thanks, but the canvas position property doesnt change when I scroll up or down. It always stays at 0,0. Although I can scroll it.

local CanvasPosition = script.Parent.Parent.CanvasPosition
local Button = script.Parent

Button.Activated:Connect(function()
    CanvasPosition = Vector2.new()
end)

Your problem here could be that you’re setting the variable to the canvas position, not the actual scrolling frame property. To do this, you need to instead do something like this:

ScrollFrame.CanvasPosition = Vector2.new()

Hope that helps!

5 Likes

You can also use Vector2.zero on a small note.

1 Like