When writing direct speech it is important to remember to use other punctuation as well as the speech marks.
For example:
"I like climbing trees," Billy said.
In this sentence there is a comma after the word 'trees' but before the closing speech marks.
If the order of the sentence is changed so that the direct speech is at the end, then the punctuation is different.
Billy said, "I like climbing trees."
There is a comma after the word 'said' and a full stop after the word 'trees' but before the closing speech marks.
If the speech ends in an exclamation mark or a question mark, then that comes before the closing speech marks and a comma is not needed.
"Help!" shouted Emma.
"Can you hear me?" asked John.
If the word order is changed the sentences look like this:
Emma shouted, "Help!"
John asked, "Can you hear me?"
The first word of the direct speech always begins with a capital letter even if it is not the start of the sentence.