I am making a save slot system for booths but the problem is that I keep on getting printed to me that the save isn’t working .
The thing that is wrong is whenever I try to save to the data store it prints to me that the save was unsuccessful
Yes I have API Enabled
If anyone has some ideas on what I am doing wrong cause I am somewhat new to datastore
local datastore = game:GetService("DataStoreService")
local Slots = datastore:GetDataStore("SaveSlot")
local player = script.Parent.Parent.Parent.Parent
local a = script.Parent
local tab = {
One = {
};
Two = {
};
Three = {
};
}
while true do
local success, data = pcall(function()
return Slots:GetAsync(player.UserId)
end)
if success then
if not data then
print("NEW PLAYER")
Slots:SetAsync(player.UserId, tab)
end
break
end
wait(2.5)
end
local function Update(data)
print("SAVING")
local slot = game.ServerStorage.Booths:FindFirstChild(player.Name)
local booth = slot.Value.Booth
print("saving to "..num)
if num == "One" then
NewTab = {
One = {
image = booth.Frame.Decal.Texture;
BottomText = booth.Primary.Bottom.SurfaceGui.TextLabel.Text;
Desc = booth.Desc.SurfaceGui.TextLabel.Text;
PrimCol = booth.Primary:GetChildren()[1];
SecCol = booth.Secondary:GetChildren()[1];
TextCol = booth.Desc.SurfaceGui.TextLabel.TextColor3;
BottomFont = booth.Primary.Bottom.SurfaceGui.TextLabel.Font;
DescFont = booth.Desc.SurfaceGui.TextLabel.Font;
};
data.Two;
data.Three;
}
end
if num == "Two" then
NewTab = {
data.One;
Two = {
image = booth.Frame.Decal.Texture;
BottomText = booth.Primary.Bottom.SurfaceGui.TextLabel.Text;
Desc = booth.Desc.SurfaceGui.TextLabel.Text;
PrimCol = booth.Primary:GetChildren()[1];
SecCol = booth.Secondary:GetChildren()[1];
TextCol = booth.Desc.SurfaceGui.TextLabel.TextColor3;
BottomFont = booth.Primary.Bottom.SurfaceGui.TextLabel.Font;
DescFont = booth.Desc.SurfaceGui.TextLabel.Font;
};
data.Three;
}
end
if num == "Three" then
NewTab = {
data.One;
data.Two;
Three = {
image = booth.Frame.Decal.Texture;
BottomText = booth.Primary.Bottom.SurfaceGui.TextLabel.Text;
Desc = booth.Desc.SurfaceGui.TextLabel.Text;
PrimCol = booth.Primary:GetChildren()[1].Color;
SecCol = booth.Secondary:GetChildren()[1].Color;
TextCol = booth.Desc.SurfaceGui.TextLabel.TextColor3;
BottomFont = booth.Primary.Bottom.SurfaceGui.TextLabel.Font;
DescFont = booth.Desc.SurfaceGui.TextLabel.Font;
};
}
end
return NewTab
end
local function save()
print("Somethings happening")
local slot = game.ServerStorage.Booths:FindFirstChild(player.Name)
if slot then -- checks if player owns booth
print("this far")
local success, data = pcall(function()
return Slots:UpdateAsync(player.UserId, Update)
end)
if success then
print("SAVE SUCESS")
else
print("SAVE FAILED AHHHHHHH")
end
end
end
local function load()
local slot = game.ServerStorage.Booths:FindFirstChild(player.Name)
if slot then -- checks if player owns booth
local booth = slot.Value.Booth
local success, data = pcall(function()
return Slots:GetAsync(player.UserId)
end)
if success then
if data then
if data.One then
print("Ah")
if data.One.image then
print("deded")
end
end
local stuff = data[num]
booth.Frame.Decal.Texture = stuff.image
booth.Primary.Bottom.SurfaceGui.TextLabel.Text = stuff.BottomText
booth.Desc.SurfaceGui.TextLabel.Text = stuff.Desc
for _, prim in pairs(booth.Primary:GetChildren()) do
prim.Color = stuff.PrimCol
end
for _, sec in pairs(booth.Secondary:GetChildren()) do
sec.Color = stuff.SecCol
end
booth.Primary.Bottom.SurfaceGui.TextLabel.TextColor3 = stuff.TextCol
booth.Desc.SurfaceGui.TextLabel.TextColor3 = stuff.TextCol
booth.Primary.Bottom.SurfaceGui.TextLabel.Font = stuff.BottomFont
booth.Desc.SurfaceGui.TextLabel.Font = stuff.DescFont
end
end
end
end
for _, gah in pairs(script.Parent:GetDescendants()) do
if gah.Name == "Save" then
gah.MouseButton1Click:Connect(function()
print("does this even work")
num = gah.Parent.Name
save()
end)
end
if gah.Name == "Load" then
gah.MouseButton1Click:Connect(function()
num = gah.Parent.Name
load()
end)
end
end