Problem with script

I’m working on a game and I’ve been trying for so long to Tween a GUI when a button is clicked, but I don’t know why it won’t work. When the player clicks on a button, another GUI moves onto the screen. It won’t work for some unknown reason. The script is

local ito = game.StarterGui.MainMenu.MenuBackground.BeginGameButton
local ito2 = script.Parent.Frame

ito.MouseButton1Click:Connect(function()
	ito2:TweenPosition(UDim2.new(0.105, 0,0.432, 0),"InOut","Quart")
end)

I’ve been experienced with building for many years, but I’m fairly new to coding, so I’m sorry if this is a simple script and I just can’t find the right answer.
Any help would be very appreciated. Thank you.

2 Likes

Is this a local script or a server script?

1 Like

This is inside a local script.

Hello! “ito” should be actually in the Player.PlayerGui not in the StarterGui, since the content of StarterGui gets actually copied to the PlayerGui.

If It’s moving another UI then you have to make sure script.Parent.Frame is the correct UI you want to move.

2 Likes

Try this:

local ito = game:GetService("Players").LocalPlayer.PlayerGui.MainMenu.MenuBackground.BeginGameButton
local ito2 = script.Parent.Frame

ito.MouseButton1Click:Connect(function()
	ito2:TweenPosition(UDim2.new(0.105, 0,0.432, 0),"InOut","Quart",)
end)

Hope it helped!

1 Like

unfortunately, that doesn’t seem to be working either. i still cant figure it out. thank you for the assistance though.

edit: wait, i adjusted the script again and it fixed! the adjustments i made were

local ito2 = script.Parent --I took away the "Frame" then I moved down to the 5th line and got rid of the "," at the end.

ito.MouseButton1Click:Connect(function()
ito2:TweenPosition(UDim2.new(0.105, 0, 0.432, 0),"InOut","Quart")
end)

Thank you so much for your help!