local players = game.Players local rblxCode game:WaitForChild("Players").PlayerAdded:Connect(function(plr) rblxCode = plr.PlayerGui["rblx.basic"].Frame.TextBox.ContentText if rblxCode == 'Print("Hello, world!")' then print("Hello, world!") end end)
How come this code would not work? When I join the game, it outputs the error: rblx.basic is not a valid member of PlayerGui "Players.pevdn.PlayerGui" Even though it definitely is. https://ibb.co/zFzc9YJ
You're trying to index the ScreenGui when the player joins, and it probably doesn't exist at that point.
You should use :WaitForChild() to make sure it definitely exists first. For example:
local gui = plr.PlayerGui:WaitForChild('rblx.basic')