Hello! I am trying to make this LocalScript that I have in my ImageButton open a frame in another ScreenGui. The LocalScript highlighted in the ImageButton in Codes, I want it to open the Frame inside “ExclusiveCodes”. I already have a script that I have been using which can open and close the GUI from pressing it twice. I wan’t to keep using this Script but make it open the frame in the different ScreenGui. I originallyhad it inside the Codes TextButton but changed it to a ScreenGui so I can make it position into the middle.
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)
-- Local script for the button you want to use to open the different frame
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.PlayerGui.ExclusiveCodes.Frame.Visible = true
end)
Okay well the script I am using, makes it open and close if you press it twice. It lets you open it, or you can press the X to close it, or click the button again to close it
Okay look, what I want help with is the script I included, I want it to open the frame inside the other Screen Gui. I never said it could already, I want it TO do that.
What you’re doing right now is very complicated. I understand your perspective but you’re really making it hard for yourself. With this script it will be quite hard and complicated to make it so you can open it in another gui. Just like @ValiantWind said, change your script to something more simple:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.PlayerGui.ExclusiveCodes.Frame.Visible = not player.PlayerGui.ExclusiveCodes.Frame.Visible
end)
I understand if you want to use your own script but this is the best way to do it.
I stated I want to use my script, because it lets me open and close it. You can open it, click it again to close it, it also prevents multiple UI to show up. There is a reason why I want to use my script
script.Parent.Parent.Frame --I don't know what your path is, but it should be something like this
--it's easy to change the path to
script.Parent.Parent.Parent.OtherScreenGui.OtherFrame --Also should look something like this