Mousebutton1down basics questions and help

Hello, im trying to make a button where when you click on it, it changes the CanvasPosition to “1,0”

i think the issue might be becuase im using a “script”
instead of a “local script” however it wont work in a local script.

heres the script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	player.PlayerGui.ToolShop.Frame.ScrollingFrame.CanvasPosition = "1,0"
end)

This May Help:

Thanks.

Use Vector2 since It requires it
Vector2.new(1,0)

1 Like

still does nothing. also i already tested to see if it would work at all by just making it invisible and it wont work

1 Like

Yes, when working with GUIs you generally want to use LocalScripts.

According to ScrollingFrame.CanvasPosition, this property uses a Vector2, not a string.

local scrollingFrame = player.PlayerGui.ToolShop.Frame.ScrollingFrame
local guiButton = script.Parent

guiButton.Activated:Connect(function()
	scrollingFrame.CanvasPosition = Vector2.new(1, 0)
end)

Aside: You should probably use GuiButton.Activated instead of MouseButton1Click.

2 Likes

works thank you very much. ill make sure to read a ton more about scripting.

2 Likes