Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does it say the frame doesn't exist when it does?

Asked by
Prioxis 673 Moderation Voter
9 years ago

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)
0
Can you take a pic of where the script is located? XtremeSpy 80 — 9y

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
0
omg I feel so stupid now haha thanks man! Prioxis 673 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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!

0
ah okay I see thank you let me test it and if it works then i'll accept Prioxis 673 — 9y

Answer this question