Here's what the frames look like inside the ScreenGui but when this script
local GUI = script.Parent.Parent local GUI2 = script.Parent.Parent.Parent:FindFirstChild("Join") script.Parent.MouseButton1Down:connect(function(click) print(game.Players.LocalPlayer.Name..' is now being Teleported..') GUI:TweenPosition(UDim2.new(1, 0, 1, 0), "Out", "Quad", 3) wait(1) GUI2:TweenPosition(UDim2.new(0, 0, 0, 0), "In", "Quad", 2) end)
This happens sometimes due to the fact that the script loads before the actual other descendants of the gui. Until they load, they're considered nil. To prevent this, you could either use the WaitForChild
method, which you can read more about here, to wait until the specified frames have loaded. Or you could just add a wait(2)
at the top of your script. The latter is less reliable but doesn't take as many lines.
script.Parent.Parent.Parent:WaitForChild("Join") script.Parent.Parent.Parent:WaitForChild() --script.Parent.Parent's name(: local GUI = script.Parent.Parent local GUI2 = script.Parent.Parent.Parent:FindFirstChild("Join") script.Parent.MouseButton1Down:connect(function(click) print(game.Players.LocalPlayer.Name..' is now being Teleported..') GUI:TweenPosition(UDim2.new(1, 0, 1, 0), "Out", "Quad", 3) wait(1) GUI2:TweenPosition(UDim2.new(0, 0, 0, 0), "In", "Quad", 2) end)
Or..
wait(2) local GUI = script.Parent.Parent local GUI2 = script.Parent.Parent.Parent:FindFirstChild("Join") script.Parent.MouseButton1Down:connect(function(click) print(game.Players.LocalPlayer.Name..' is now being Teleported..') GUI:TweenPosition(UDim2.new(1, 0, 1, 0), "Out", "Quad", 3) wait(1) GUI2:TweenPosition(UDim2.new(0, 0, 0, 0), "In", "Quad", 2) end)
I think you may have used too many Parents to define GUI2. Note that the ScreenGui "Main" was defined as script.Parent.Parent. You defined GUI2 as script.Parent.Parent.Parent:FindFirstChild("Join"), which is equivalent to GUI.Parent:FindFirstChild("Join"). See the problem here? You tried to find a child name "Join" in the Parent of ScreenGui (AKA PlayerGui) when none exists! This should fix it.
local GUI = script.Parent.Parent local GUI2 = GUI:FindFirstChild("Join")
If my answer helped, you can upvote and accept it. If you have any questions, just ask!