I've tried to make this script many times but It never works! I don't know what is wrong with my code. Here it is:
local TextBox = game.StarterGui.ScreenGui.TextBox
local TextButton = game.StarterGui.ScreenGui.TextButton
TextButton.MouseButton1Click:Connect(function)
print(TextBox.Text)
end

2 comments
Thats because youre accessing the starterGui, not the playerGui.
so textbox would look something like this: local TextBox = game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui.TextBox if this is a local script