local event = Instance.new("RemoteEvent") -- creates the event object
event.Parent = game.Workspace -- puts the event into the Workspace
event.Name = "MyServerEvent"
local RepStorage = game:GetService("ReplicatedStorage")
local remote = RepStorage:WaitForChild("Remote")
local Button = script.Parent
local DSService = game:GetService('DataStoreService'):GetDataStore('ToonApperance')
--SaveThemUp
event.OnServerEvent:connect(function(player)
--
local Tlayer = player.Character
local ToonChoosen = Tlayer:WaitForChild("Chest").ValuesFolder.ToonChoosen
local ToonColorHead = Tlayer:WaitForChild("ToonHead").ValuesFolder.Head
local ToonShirtColor = Tlayer:WaitForChild("Chest").ValuesFolder.Shirt
local ToonArmColor = Tlayer:WaitForChild("Chest").ValuesFolder.Arms
local ToonLegColor = Tlayer:WaitForChild("Chest").ValuesFolder.Legs
local ToonBttomsColor = Tlayer:WaitForChild("Chest").ValuesFolder.Bottoms
--
print("Save Event Recieved Saving")
local UniqueKey = 'id-'..player.userId
local Savetable = {ToonChoosen.Value,ToonColorHead.Value,ToonShirtColor.Value,ToonBttomsColor.Value,ToonLegColor.Value,ToonArmColor.Value}
DSService:SetAsync(UniqueKey,Savetable)
end)
My datastore script will not work for some unknown reason for example. I press the gui button and the remote event works because print("Save Event Recieved Saving") shows up in the dev console but the values do not save at all. As when i try to call it using getasync the value is not returned to any of the values i wanted to save. I tried looking at many datastore examples most are just leaderboard stuff. Help please!
Below is the get async
local DataStore = game:GetService("DataStoreService"):GetDataStore("ToonApperance")
game.Players.PlayerAdded:connect(function(plr)
--Now For Defining Variables(Creates Values Too)
local UniqueKey = 'id-'..plr.userId
local ToonChoosen = Instance.new("IntValue", plr)
local ToonColorHead = Instance.new("BrickColorValue", plr)
local ToonShirtColor = Instance.new("BrickColorValue", plr)
local ToonArmColor = Instance.new("BrickColorValue", plr)
local ToonLegColor = Instance.new("BrickColorValue", plr)
local ToonBttomsColor = Instance.new("BrickColorValue", plr)
ToonChoosen.Name = "ToonChoosen"
ToonColorHead.Name = "ToonColorHead"
ToonShirtColor.Name = "ToonShirtColor"
ToonArmColor.Name = "ToonArmColor"
ToonLegColor.Name = "ToonLegColor"
ToonBttomsColor.Name = "ToonBttomsColor"
local GetSaved = DataStore:GetAsync(UniqueKey)
if GetSaved then
ToonChoosen.Value = GetSaved[1]
ToonColorHead.Value = GetSaved[2]
ToonShirtColor.Value = GetSaved[3]
ToonArmColor.Value = GetSaved[4]
ToonLegColor.Value = GetSaved[5]
ToonBttomsColor.Value = GetSaved[6]
print("Value Set For Toon")
end
end)

11 comments
When you use GetAsync to retrieve what you saved, what does it return? nil? Also, you have an issue on line 28 where you're saving VariablesToSave5 twice -- I imagine the second time it should be VariablesToSave6.
It doesnt return a nil value. this is the getasync script
What does it return then? Regardless of what your GetAsync script does that you just added to the OP, what it gives you depends on what was stored in the DataStore to begin with.
13:28:43.274 - Cannot store Array in DataStore
also rewrote the script
That's an error you'll get from saving. After rewriting the script, do you still get that error?
yeah thats the error i get now its something to do with the table on line 22
Here is a printTable function: http://pastebin.com/E7JXRffp Use this to print out Savetable before doing SetAsync on line 23 and post back with the results.
where does this go? Line 22? and do i have to remove the things already in line 22?
No, leave your SetAsync code the same. Paste that printTable function at the top of the script, and then between lines 22 and 23 put printTable(Savetable)
{ [1] = 1; [2] = Pink; [3] = Br. yellowish orange; [4] = Pink; [5] = Pink; [6] = Mulberry; } thats what it printed