Disclaimer: This tutorial is how to send and log data to a google sheets document, this tutorial doesn’t show how to get/retrieve data from a sheet.
This tutorial focuses on taking in-game data and sending it to a Google Spreadsheet document. Most tutorials I found were outdated from 2015. This tutorial is quite similar to @Dummiez’s but updated to work in 2023. Dummiez 2015 Tutorial.
Keep in mind, Google spreadsheets has limits whether its size or how many requests you can do in a fixed period of time.
-
Create a new Google Spreadsheet. In your Roblox studio place, create an empty script. Make sure your studio place can make HTTP requests, this will be in “Game Settings”.
-
Next we want to create a form to submit the data with. In the spreadsheet, Click on Tools → Create New Form.
-
In your Google form, add in any data (as questions) you would like to log. Each question should be of the short answer type.
-
Make sure your form is accepting answers and is not a quiz. This should be the default anyways. (Modifyable in settings).
-
When you entered all your questions, click send at the top. Take the URL it gives you (take the long URL not the Shortened link), the link should look like this: https://docs.google.com/forms/d/e/abcde123/edit
That space in the middle “abcde123” will be your Form key, save that as a string variable in your script.
local formKey = "abcde123"
-
In the Form, click on more (3 dots at the top) → Get pre-filled link
On the shown page, type your answers as something identifiable, or just paste the question as the answer (This is only necessary for readability in the next step)
Make sure every box is filled out. At the bottom, click “Get Link” and copy it.
-
That link will look something like this:
https://docs.google.com/forms/d/e/abcde123/viewform?usp=pp_url&entry.0123456789=PlayerCount&entry.456789123=RandomGameStat1&entry.789123456=RandomGameStat2
You can see the pattern&entry.[randomNumber] = yourAnswer
. This number is your question entry.
Copy each question entry into its own variable, name or comment the variables based on its associated question. If you typed distinct answers in the last step, you should know which entry corresponds to which question.
local PlayerCount = "0123456789"
local RandomGameStat1 = "456789123"
local RandomGameStat2 = "789123456"
- Using the following function, add in your variables
-- Make sure you define local HttpService = game:GetService("HttpService")
local function logSheet(variables)
local url = "https://docs.google.com/forms/d/e/" .. formKey.."/formResponse?usp=pp_url" --formKey would be your key like "abcde123"
.."&entry."..PlayerCount .."=".. variables[1] -- PlayerCount would be your question entry, variables[1] would be the data that your would want to set for that question/entry
.."&entry."..RandomGameStat1 .."="..variables[2] -- RandomGameStat1 would be your question entry, variables[2] would be the data that your would want to set for that question/entry
.."&entry."..RandomGameStat2 .."="..variables[3] -- RandomGameStat2 would be your question entry, variables[3] would be the data that your would want to set for that question/entry
-- add more lines if you have more questions to submit
HttpService:PostAsync(url, "")
end
logSheet( { 1, 2, 3 } )
-
Go back to your Google Spreadsheet. On the bottom, there should be a button with something like “Form Responses 1”, click on that.
-
Run your function, you should notice the data you entered will start appearing in the spreadsheet along with a time stamp.
: )