Im trying to make a script where after a part named “Camera” loads into the game, the Gui disappears.
How would I go about making the Gui turn invisible able ‘Camera’ has loaded into workspace?
Im trying to make a script where after a part named “Camera” loads into the game, the Gui disappears.
How would I go about making the Gui turn invisible able ‘Camera’ has loaded into workspace?
workspace:WaitForChild("Camera") -- yields the thread until it finds "Camera"
-- make the GUI invisible
There is already an instance in workspace called called Camera but it’s not a part so it might bug up your script if you use WaitForChild. So we can use a while loop.
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local localPlayer = Players.LocalPlayer :: Player
local playerGui = localPlayer:WaitForChild("PlayerGui")
local targetGui = playerGui:WaitForChild("TARGET_GUI") -- CHANGE TARGET_GUI TO THE NAME OF YOUR SCREEN GUI
local cameraPart = Workspace:FindFirstChild("Camera") :: BasePart?
while not cameraPart or not cameraPart:IsA("BasePart") do
cameraPart = Workspace.ChildAdded:Wait()
end
targetGui.Enabled = false
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.