So I am trying to find a screen gui in my game but the FindFirstChild Check is not working…
while true do
wait(0.5)
local FFC = game:FindFirstChild("ScreenGui")
if FCC then print("Gui")
local er = pcall(FFC) -- Ignore this
if er then game.Players.LocalPlayer:Kick() -- and this
end
end
end
I know it uses a bad syntax with while true do and stuff but it’s just a work in progress, help would be appreciated. Thanks.
you need to have the player gui
local FFC = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ScreenGui")
if not FFC then print("There isn't a gui here")
game.Players.LocalPlayer:Kick()
end
since there is no ScreenGui directly parented to the game object, then FindFirstChild will return nil
Yeah but I want it to search the whole game. It was working a couple days ago I don’t know what happend.
searching the entire game is kind of slow but you could do it with this function
function FindFirstDescendant(Instance, name)
for i,v in pairs(Instance:GetDescendants()) do
if v.Name == name then return v end
end
end
local Desc = FindFirstDescendant(game, "ScreenGui")
I can’t because it doesn’t run at a high enough security level:
Didn’t work either… It just does nothing
do game:FindFirstChild("ScreenGui", true)
keep in mind this will return the first ScreenGui, and this is also really slow
1 Like