But when I close it and press the block its clones the GUI again. As I mentioned the click detector clones the GUI so is there any way I can open it again without cloning it again at the same time. Also the GUI Is in the workspace.
Or how can I reparent the GUI to the PlayerGui with a script when I pressed a button. Sorry its a bit complicated for as I’m new at LUA Scripting.
clickdetector.mouseclick (player)
if player.PlayerGui:FindFirstChild(yourGui.Name) then
player.PlayerGui[yourGui.Name].Frame.Visible = true
else
yourGui:Clone().Parent = player.PlayerGui
end
end)
it’s basically just like an informal way to explain an algorithm so it basically looks written in english and helps you to understand the steps to writing code but it isnt actual code
for i,v in pairs(model:GetDescendants()) do
print(v.Name)
if v:IsA("ClickDetector") then
print("Step1")
v.MouseClick:connect(function(player)
if player.PlayerGui:FindFirstChild("SCIGui") then
player.PlayerGui["SCIGui"].Backround.Visible = true
else
gui:Clone().Parent = player.PlayerGui
end
end)
end
end
So the problem was that we are making the frame visible for all players in a server script so I made a Remote Event thats runs from the server to local script and it worked perfectly.
local function OpenGui()
player.PlayerGui:WaitForChild("SCIGui").Backround.Visible = true
end
game.Workspace.ShranksSCI.OpenGUI.OnClientEvent:Connect(OpenGui)
for i,v in pairs(model:GetDescendants()) do
print(v.Name)
if v:IsA("ClickDetector") then
print("Step1")
v.MouseClick:connect(function(player)
if player.PlayerGui:FindFirstChild("SCIGui") then
script.Parent.OpenGUI:FireAllClients()
else
gui:Clone().Parent = player.PlayerGui
end
end)
end
end