Hi!
I am right now making my Settings save. It isn’t saving, because I don’t see the “Saved!” message, I also don’t see the error message. What’s wrong ?
Thanks!
game.Players.PlayerRemoving:Connect(function(plr)
local data = {
Time = plr:FindFirstChild("leaderstats").TIME.Value,
Flex = plr:FindFirstChild("leaderstats").Flex_Points.Value,
Rap = plr:GetAttribute("RapidLoad"),
Themecolor = plr:FindFirstChild("ThemeColor").Value,
}
local success, whoops = pcall(function()
ds:SetAsync("id_"..plr.UserId, data)
end)
if success then
print("Data saved successfully!")
else
warn("An error occurred saving the data, more info: ", whoops)
end
end)
while task.wait(60) do
for i, plr in pairs(game.Players:GetPlayers()) do
local data = {
Rapid = plr:FindFirstChild("Settings").RapidLoad.Value,
Flex = plr:FindFirstChild("leaderstats").Flex_Points.Value,
Rap = plr:GetAttribute("RapidLoad").Value,
Themecolor = plr:WaitForChild("ThemeColor").Value,
}
local success, whoops = pcall(function()
ds:SetAsync("id_"..plr.UserId.."_settings", data)
end)
if success then
print("Settings saved successfully!")
else
warn("An error occurred saving the settings, more info: ", whoops)
end
end
end
The stream is here if you want to see a video, I’m retrying it over and over as of right now.
Just a warning but PlayerRemoving often (possibly always) doesn’t fire in Studio, although you mentioned the problem still persists even with a every 60 seconds attempt. I’ll take a look at that.
game.Players.PlayerRemoving:Connect(function(plr)
local data = {
Time = plr:WaitForChild("leaderstats").TIME.Value,
Flex = plr:WaitForChild("leaderstats").Flex_Points.Value,
Rap = plr:GetAttribute("RapidLoad"),
Themecolor = plr:WaitFirstChild("ThemeColor").Value,
}
local success, whoops = pcall(function()
ds:SetAsync("id_"..plr.UserId, data)
end)
if success then
print("Data saved successfully!")
else
warn("An error occurred saving the data, more info: ", whoops)
end
end)
while task.wait(60) do
for i, plr in pairs(game.Players:GetPlayers()) do
local data = {
Rapid = plr:WaitForChild("Settings").RapidLoad.Value,
Flex = plr:WaitForChild("leaderstats").Flex_Points.Value,
Rap = plr:GetAttribute("RapidLoad").Value,
Themecolor = plr:WaitForChild("ThemeColor").Value,
}
local success, whoops = pcall(function()
ds:SetAsync("id_"..plr.UserId.."_settings", data)
end)
if success then
print("Settings saved successfully!")
else
warn("An error occurred saving the settings, more info: ", whoops)
end
end
end
Does this change result in any “infinite yield” warnings in console? If it does then one or more of your references are to invalid instances which either don’t exist or don’t exist in the correct directory (location) specified.
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
local RunService = game:GetService("RunService")
local ButtonsNames = {
["Black"] = "Black",
["Red"] = "Red",
["Pink"] = "Pink",
["Green"] = "Green",
["Blusish"] = "Blusish",
["Orange"] = "Orange",
["Lavender"] = "Lavender"
}
game.Players.PlayerAdded:Connect(function(plr)
local plrkey = "id_"..plr.UserId.."_settings"
local save1 = plr:WaitForChild("Settings"):WaitForChild("RapidLoad")
local save2 = plr:WaitForChild("Settings"):WaitForChild("SomethingElse")
local save3 = plr:WaitForChild("Settings"):WaitForChild("SomethingElse")
local themeColor = plr:WaitForChild("ThemeColor")
local data
local success, whoops = pcall(function()
data = ds:GetAsync(plrkey)
end)
if success and data then
save1.Value = data.Time
save2.Value = data.Flex
save3.Value = data.Rap
themeColor.Value = data.Themecolor
game.ReplicatedStorage:WaitForChild("ThemeColor"):FireClient(plr,data.Themecolor)
print("Loaded data to: ", plr.Name)
else
if not data then
warn("The user has no data! more info: ", whoops)
else
plr:Kick("Data could not load, probably due to an error with Roblox.\nYou have been kicked to prevent damage to your data.")
end
end
end)
while task.wait(60) do
for i, plr in pairs(game.Players:GetPlayers()) do
local data = {
Rapid = plr:WaitForChild("Settings").RapidLoad.Value,
Flex = plr:WaitForChild("leaderstats").Flex_Points.Value,
Themecolor = plr:WaitForChild("ThemeColor").Value,
}
local success, whoops = pcall(function()
ds:SetAsync("id_"..plr.UserId.."_settings", data)
end)
if success then
print("Settings saved successfully!")
else
warn("An error occurred saving the settings, more info: ", whoops)
end
end
end