Hello! How can I parent this script to a Frame that is located inside a different ScreenGui? Here is the script
script.Parent.MouseButton1Click:Connect(function()
for _, v in pairs (script.Parent.Parent.Parent.Parent:GetChildren()) do
if v:IsA("Frame") then
for _, nV in pairs(v:GetChildren()) do
if nV:IsA("TextButton") then
for _, v2 in pairs(nV:GetChildren()) do
if v2:IsA("Frame") then
if v2 == script.Parent.Parent.Frame then
v2.Visible = not v2.Visible
else
v2.Visible = false
end
end
end
end
end
end
end
end)
I still want to use that script, but how can I make it parent to this Frame inside “ExclusiveCodes”
Honestly, there’s no need to reparent, just set a variable that is that frame, and then you can use the script as if it were there, scripts parents, generally don’t matter. You can just run the same function, but instead of script.Parent, use a variable for the frame you want.
Yes, it’s a variable so it would have to be there. Bens suggestion may also work though. Not to sure what you want to though! Considering it’s a frame and MouseButton1Down wouldn’t work on it!
script.Parent.Parent.Parent.Parent.Parent.ExclusiveCodes.Frame
script.Parent.MouseButton1Click:Connect(function()
for _, v in pairs (script.Parent.Parent.Parent.Parent:GetChildren()) do
if v:IsA("Frame") then
for _, nV in pairs(v:GetChildren()) do
if nV:IsA("TextButton") then
for _, v2 in pairs(nV:GetChildren()) do
if v2:IsA("Frame") then
if v2 == script.Parent.Parent.Frame then
v2.Visible = not v2.Visible
else
v2.Visible = false
end
end
end
end
end
end
end
end)
You gotta set the variable!
make a variable by doing: local TestVariable = script.Parent.Parent.Parent.Parent.Parent.ExclusiveCodes.Frame
TestVariable.MouseButton1Click:Connect(function()
for _, v in pairs (script.Parent.Parent.Parent.Parent:GetChildren()) do
if v:IsA(“Frame”) then
for _, nV in pairs(v:GetChildren()) do
if nV:IsA(“TextButton”) then
for _, v2 in pairs(nV:GetChildren()) do
if v2:IsA(“Frame”) then
if v2 == script.Parent.Parent.Frame then
v2.Visible = not v2.Visible
else
v2.Visible = false
end
end
end
end
end
end
end
local TestVariable = script.Parent.Parent.Parent.Parent.Parent.ExclusiveCodes.Frame
TestVariable.MouseButton1Click:Connect(function()
for _, v in pairs (script.Parent.Parent.Parent.Parent:GetChildren()) do
if v:IsA("Frame") then
for _, nV in pairs(v:GetChildren()) do
if nV:IsA("TextButton") then
for _, v2 in pairs(nV:GetChildren()) do
if v2:IsA("Frame") then
if v2 == script.Parent.Parent.Frame then
v2.Visible = not v2.Visible
else
v2.Visible = false
end
end
end
end
end
end
end
end)