I watched a few tutorials and wrote this script for my game, It saves textbox text, It is outputting N/A and not setting what the player put in:
'''lua
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("MainMenuDataStore")
local Template = {
Text1 = "N/A",
Text2 = "N/A",
Text3 = "N/A",
Text4 = "N/A"
}
game.Players.PlayerRemoving:Connect(function(player)
Template.Text1 = player.PlayerGui.PlayGui.Frame.SaveSlot1Frame.NameLabel.Text <---- EMPHASIS ON THIS LINE
local sucess, err = pcall(function()
local data = DataStore:GetAsync(player.UserId)
print(data)
end)
if sucess then
DataStore:SetAsync(player.UserId, Template)
else
warn(err)
end
print(DataStore:GetAsync(player.UserId).Text1)
end)
game.Players.PlayerAdded:Connect(function(player)
pcall(function()
return DataStore:GetAsync(player.UserId)
end)
wait(0.5)
print(DataStore:GetAsync(player.UserId).Text1)
player.PlayerGui.PlayGui.Frame.SaveSlot1Frame.NameLabel.Text = DataStore:GetAsync(player.UserId).Text1
end)
lua'''
** You are now Level 2! **