Welcome to The Soup @ClarisUSER. I hope The Soup becomes a valuable FileMaker resource for you.
I assume you operate a flight school. I also assume your solution has a student table and a training session table. You can create a field in the student table that sums the hours flown field of the training session table.
There is no need for a button, unless I misunderstood your request.
The normal "FileMaker" way of doing this would not involve scripting or a button at all.
You would have two Tables, a users table and a flights table.
The flights table would be a list of flights (with some sort of field that indicated the # of training hours, e.g. "FlightHours")
The two tables would be related by an ID field (probably Student ID).
You then create a Calculated field in the users table which has a formula something like this:
TotalFlightHours = Sum(Flights::FlightHours)
No need for a button or script.
[Edit to add: seems like bdbd and I came up with basically the same solution. The FileMaker Force is strong here]
[Edit 2: your title is "last 7 days". If you wanted to limit this calculation to only flights in the past week, you could do this a few ways. One way would be to create a relationship between the two tables that uses the < and > relationship operators, e.g. a relationship where:
Then it's a classic case of running a bunch of finds in the training session table to compute the numbers. If the fields that will display the results are not in the same table, you will need to store the results temporarily in variables or globals fields.