Tween occurs 1 time but not everytime i open or close plugin gui

this is my plugin’s script, when i open the plugin the gui pops up with tween but when i close plugin the closing tween doesn’t work and when i open it after the tween doesn’t work here is the script:


1. local toolbar = plugin:CreateToolbar("Player Character Loader v1")
2. local btn =  toolbar:CreateButton("Load Character", "Load Character", "rbxassetid://8434139067")

3. local gui = script:WaitForChild("Gui")

4. btn.Click:Connect(function()
5. 	if gui.Parent == script then
6. 		gui.Parent = game:WaitForChild("CoreGui")
7. 		local frame = gui:WaitForChild("Background")
8. 		frame:TweenPosition(UDim2.new(0.339, 0,0.232, 0), "Out", "Back")
9. 	else
10. 		gui.Parent = script
11. 		frame:TweenPosition(UDim2.new(1,1,1,1), "Out", "Back")
12. 	end
13. end)
1 Like

You are tweening it after you move the gui to the script, when you should be moving it to the script after the tween has concluded. Try adjusting the order of code, and add a wait statement, and see if it affects it.

1 Like

i tween it when it moves into the script so that it closes smoothly

It starts moving after you move it into the script. By the time it’s moving, it’s already parented into the script and hence is not visible to the user.

deleted the tween on close still same thing

The issue isn’t that the tween thing exists - the issue is that you are moving the GUI out of CoreGui too early.

lemme try
11111111111111111111111111111111111