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)
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.
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
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.
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)