Why wont this tween work?

Ok so basicly im making a menu screen but the x button tween doesnt work for one of the frames the button to make the frame come works just not the x button the code:
Also when i click the x button to test it it sets the position just it doesnt tween it…

 local x = script.Parent
   local tweenservice = game:GetService("TweenService")
    local creditsframe = game.StarterGui.Menu.CreditsFrame


 x.MouseButton1Click:Connect(function()
creditsframe:TweenPosition(UDim2.new(-2.03, 0, 0.358, 0), Enum.EasingDirection.In, 
     Enum.EasingStyle.Bounce, 3, true) 



end)

You are using StarterGui when you should be using PlayerGui which is a child of the Player object.

1 Like

Ive tried using script.parent to though but it still didnt work.

I don’t know what you mean by this?

1 Like

This is what i mean aso i dont know how to refrence player gui

		 local x = script.Parent
		 local tweenservice = game:GetService("TweenService")
		 local creditsframe = script.Parent


		 x.MouseButton1Click:Connect(function()
			creditsframe:TweenPosition(UDim2.new(-2.03, 0, 0.358, 0), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, 3, true) 



		end)

local Player = game:GetService(“Players”).LocalPlayer

local PlayerGui = Player:WaitForChild(“PlayerGui”)

If this code is placed in a ServerScript, the server won’t be able to see any MouseButton1 interactions done by the player locally. Make sure this code is running in a LocalScript.

The Player’s GUI can be accessed by doing the following in a LocalScript.

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

Fom there, you can index any UI element following the StarterGui layout.

PlayerGui.ScreenGui.Frame.Button – Whichever element you’re trying to index.

1 Like

Now i get this error
00:19:33.127 Players.spydercam500.PlayerGui.Menu.CreditsFrame.TextButton.LocalScript:2: Expected identifier when parsing expression, got Unicode character U+201c (did you mean ‘"’?) - Studio - LocalScript:2

Replace the quotation marks with the ones on your keyboard. Mobile quotation marks are different for some reason.

1 Like

You do not need game:GetService("TweenService") unless you’re creating tween objects. That line can be removed since you’re utilizing the TweenPosition method linked to UI elements.

2 Likes

Oh i never knew that im new to scripting so thanks!

1 Like
script be like:
local x = script.Parent
local tweenservice = game:GetService("TweenService")

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

local creditsframe = PlayerGui:WaitForChild("Menu").CreditsFrame
 x.MouseButton1Click:Connect(function()
    creditsframe:TweenPosition(UDim2.new(-2.03, 0, 0.358, 0), Enum.EasingDirection.In, 
         Enum.EasingStyle.Bounce, 3, true)
end)