local reason game.Players.ChildAdded:Connect(function(plr) local function kick() plr:Kick(reason) end plr:WaitForChild("PlayerGui").ChildAdded:Connect(function(child) if child:IsA("ScreenGui") then if child.Name == "BubbleChat" or child.Name == "Chat" or child.Name == "Freecam" then print('loaded') else local reason = 'Executing a ScreenGUI' print(reason) kick() end end end) end)
So, whenever I join the game, the first thing I see in the output is "loaded" because I made it print loaded whenever a child with the name "BubbleChat", "Chat", or "Freecam" is added into PlayerGui.
But. whenever I go into Explorer (in-game) and insert a new ScreenGui into my PlayerGui, it is supposed to kick the player and print the reason, "Executing a ScreenGUI". But unfortunately, it doesn't do that.
I really do not know what the error is here. There is no error in the output. Help is greatly appreciated!
I figured it out, I made the script a LocalScript and put it into StarterPlayerScripts. I also changed the script to:
local reason local plr = script.Parent.Parent local function kick() plr:Kick(reason) end plr:WaitForChild("PlayerGui").ChildAdded:Connect(function(child) if child:IsA("ScreenGui") then if child.Name == "BubbleChat" or child.Name == "Chat" or child.Name == "Freecam" then print('loaded') else local reason = 'Executing a ScreenGUI' print(reason) kick() end end end)