Hi guys, I would like to ask solution about saving data from Roblox Studio to Google Sheet API
-
What do you want to achieve? Keep it simple and clear!
I want to save the player’s input by using Roblox Open Cloud API (testing collecting data from Roblox Studio). I’m currently using the ProfileService to create and save Datastores and HttpService to make a POST request. -
What is the issue? Include screenshots / videos if possible!
When I’m test it in runtime, the HTTP 500 error always pop ups and do not send the data to the url. I doing the research say that the thread is running at client side because of my local script. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is my server-side script.
-- This is an example Lua code block
remoteEvent.OnServerEvent:Connect(function(player: Player, text: string)
local playerID = players:GetUserIdFromNameAsync(player.Name)
local profile = playerData.Profiles[player]
local tempTable = {}
for i, v in pairs(text) do
table.insert(tempTable, v)
end
profile.Data.Name = player.Name
profile.Data.statement = tempTable
player.leaderstats["statements 1"].Value = profile.Data.statement[1]
player.leaderstats["statements 2"].Value = profile.Data.statement[2]
player.leaderstats["statements 3"].Value = profile.Data.statement[3]
--print(profile.Data)
local json = https:JSONEncode(profile.Data)
DataShow.SurfaceGui.TextLabel.Text = json -- This will print the JSON result to the part in workspace
local url = "https://roproxy.com/v1/users/"..playerID
local success, err = pcall(function()
https:PostAsync(url, profile.Data, Enum.HttpContentType.ApplicationJson)
end)
if not success then
warn(err)
end
end)
And this is my local script within text button
local btn = script.Parent
local textbox = btn.Parent.TextBox
local event = game:GetService("ReplicatedStorage").SendPlayerText
local function splitString(inputStr, separator)
if separator == nil then
separator = "%c%p"
end
local tableStore = {}
for str in string.gmatch(inputStr, "([^"..separator.."]+)") do
table.insert(tableStore, str)
end
return table.unpack(tableStore)
end
local function SendMessage()
local text = {splitString(textbox.Text)}
event:FireServer(text)
end
btn.MouseButton1Click:Connect(SendMessage)