Sorry for my bad coding but I can’t get my datastores to work
local DataStoreService = game:GetService("DataStoreService")
local E1 = DataStoreService:GetDataStore("E1")
local E2 = DataStoreService:GetDataStore("E2")
local E3 = DataStoreService:GetDataStore("E3")
local E4 = DataStoreService:GetDataStore("E4")
game.Players.PlayerAdded:Connect(function(plr)
local repStorage = game:GetService("ReplicatedStorage")
local data
local data2
local data3
local data4
local success, errormessage = pcall(function()
data = E1:GetAsync(plr.UserId.."-E1")
data2 = E2:GetAsync(plr.UserId.."-E2")
data3 = E3:GetAsync(plr.UserId.."-E3")
data4 = E4:GetAsync(plr.UserId.."-E4")
end)
if success then
repStorage.Completions.Ending1Complete.Value = data
repStorage.Completions.Ending2Complete.Value = data2
repStorage.Completions.Ending3Complete.Value = data3
repStorage.Completions.Ending4Complete.Value = data4
print("Data Successfully Loaded")
else
print("An Error Occured Loading Data: ".. errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local repStorage = game:GetService("ReplicatedStorage")
local success, errormessage = pcall(function()
E1:SetAsync(plr.UserId.."-E1", repStorage.Completions.Ending1Complete.Value)
E2:SetAsync(plr.UserId.."-E2", repStorage.Completions.Ending2Complete.Value)
E3:SetAsync(plr.UserId.."-E3", repStorage.Completions.Ending3Complete.Value)
E4:SetAsync(plr.UserId.."-E4", repStorage.Completions.Ending4Complete.Value)
end)
if success then
print("Data Saved Successfully")
else
print("Error loading data, Error Message: "..errormessage)
end
end)
It won’t save or load the data and gives no error message. It also says it was successful but doesn’t work