What do I want to achieve?
I want to store intValue
in the Data Store
successfully.
What is my problem!
Well, I am not sure that my code is working correctly or there is some mistakes I made.
The code that I wrote:
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local CStore = DSS:GetDataStore("CSystemStorage")
Players.PlayerAdded:Connect(function()
local CFile = Instance.new("Folder")
CFile.Name = "CSystem"
CFile.Parent = player
local Copper = Instance.new("IntValue")
Copper.Name = "Copper"
Copper.Value = 0
Copper.Parent = player.CSystem
local Silver = Instance.new("IntValue")
Silver.Name = "Silver"
Silver.Value = 0
Silver.Parent = player.CSystem
local Gold = Instance.new("IntValue")
Gold.Name = "Gold"
Gold.Value = 0
Gold.Parent = player.CSystem
local CS
local SS
local GS
local Success , errorM = pcall(function()
CS = CStore:GetAsync(player.UserId.."-Copper")
SS = CStore:GetAsync(player.UserId.."-Silver")
GS = CStore:GetAsync(player.UserId.."-Gold")
end)
if Success then
print(player.Name.." - Your data is in good condition.")
Copper.Value = CS
Silver.Value = SS
Gold.Value = GS
else
print(player.Name.." - Whoops! I think you might not have your data saved!")
warn(errorM)
end
end)
Players.PlayerRemoving:Connect(function(player)
-----------------CStore------------------
local Copper = player.CSystem.Copper.Value
local Silver = player.CSystem.Silver.Value
local Gold = player.CSystem.Gold.Value
local Success , errorM = pcall(function()
CStore:SetAsync(player.UserId.."-Copper",Copper)
CStore:SetAsync(player.UserId.."-Silver",Silver)
CStore:SetAsync(player.UserId.."-Gold",Gold)
end)
if Success then
print("C-System has been saved for - "..player)
else
print("There was a leak in the Data Storage! - "..player)
warn(errorM)
end
end)
The Output I get from the RobloxStudio:
Mid0riyama - Your data is in good condition.
16:14:43.512 - Disconnect from 127.0.0.1|64203
16:14:43.515 - ServerScriptService.P-Core:73: attempt to concatenate string with userdata
My problem is this output. Is this working or not I am not sure.
16:14:43.515 - ServerScriptService.P-Core:73: attempt to concatenate string with userdata"