local module = require(script.DataStore)
local dataStore = game:GetService("DataStoreService"):GetDataStore("PlayerData")
game.ReplicatedStorage.Remotes.RemoveData.OnServerEvent:Connect(function(player)
local key = player.UserId
dataStore:RemoveAsync(key)
end)
local char = workspace.Character
game.ReplicatedStorage.Remotes.InputCharData.OnServerEvent:Connect(function(player, magicType)
local dataa = module.makeTable(player)
dataa.magic = magicType
dataa.level = player.Database.Level.Value
dataa.xp = player.Database.Level.XP.Value
dataa.xpn = player.Database.Level.XPN.Value
dataa.magicLevel = player.Database.MagicLevel.Value
dataa.magicXP = player.Database.MagicLevel.MagicXP.Value
dataa.magicXPN = player.Database.MagicLevel.MagicXPN.Value
dataa.magicEnergy = player.Database.MagicEnergy.Value
dataa.silver = player.Database.Silver.Value
dataa.hp = player.Database.HP.Value
dataa.hair1 = char.Hair.Handle.Mesh.MeshId
dataa.hair2 = char.Hair2.Handle.Mesh.MeshId
dataa.hair1Color = char.Hair.Handle.Mesh.VertexColor
dataa.hair2Color = char.Hair2.Handle.Mesh.VertexColor
dataa.hair1Offset = char.Hair.Handle.Mesh.Offset
dataa.hair2Offset = char.Hair2.Handle.Mesh.Offset
dataa.skinColor = char["Body Colors"].RightArmColor3
dataa.face = char.Hed.Face.Texture
dataa.shirt = char.Shirt.ShirtTemplate
dataa.pants = char.Pants.PantsTemplate
dataa.shirtColor = char.Shirt.Color3
dataa.pantsColor = char.Pants.Color3
game.ReplicatedStorage.Remotes.Teleport.OnServerEvent:Connect(function(player)
module.SaveData(player) -- here's problem
game:GetService("TeleportService"):Teleport(4398454020, player, dataa)
end)
end)
SaveData function and makeTable function:
function module.makeTable(player)
local data = {
magic = player.Database.Magic.Value,
magicLevel = player.Database.MagicLevel.Value,
magicXP = player.Database.MagicLevel.MagicXP.Value,
magicXPN = player.Database.MagicLevel.MagicXPN.Value,
level = player.Database.Level.Value,
xp = player.Database.Level.XP.Value,
xpn = player.Database.Level.XPN.Value,
silver = player.Database.Silver.Value,
hp = player.Database.HP.Value,
hair1 = player.Database.Hair1.Value,
hair1Color = player.Database.Hair1.Hair1Color.Value,
hair1Offset = player.Database.Hair1.Hair1Offset.Value,
hair2 = player.Database.Hair2.Value,
hair2Color = player.Database.Hair2.Hair2Color.Value,
hair2Offset = player.Database.Hair2.Hair2Offset.Value,
skinColor = player.Database.SkinColor.Value,
face = player.Database.Face.Value,
shirt = player.Database.Shirt.Value,
shirtColor = player.Database.ShirtColor.Value,
pants = player.Database.Pants.Value,
pantsColor = player.Database.PantsColor.Value,
}
return data
end
function module.SaveData(player)
local key = player.UserId
local data = module.makeTable(player)
dataStore:SetAsync(key, data) -- line 37
end

20 comments
Can you print out the typeof() each value you're saving to the datastore?
done
I will wait. I am waiting for train and have nowhere to go.
heck. might have to team create if that's okay with you. I know it's an issue with saving something you're not supposed to but can't figure it out what that is. Would help if I could use Roblox's debugger and play around with it
ok sure.
did you accept friend request?
Yes
https://www.roblox.com/games/4109129754/a
hang ooonnnnn gonna take a while with this crappy wifi
okay i can wait
see edit
thanks
yeah, no prob. if you need help converting them back let me know.
what is str and tab supposed to be? string and table?
Yes string and mytable, I changed the variable names and must've missed those. Might want to change the variable names to something other than just 'string' though since Roblox recognizes it as a keyword
how would i make a stringToColor3 function though
Same thing, but instead of return vector3.new(), return color3.new()
by the way, is it possible to just use tostring() and tonumber() instead of the functions?
no, sadly not :(
i get an error when i use stringToVector3() for hair1Color saying bad argument #1 to gmatch (string expected, got nil)