So i was making a really unnecessary OS thing but when i try to save data (a remote event fired from a local script) it says on the output that it succed but it returns a nil value when i try to GetAsync. I'm not an expert on scripting so i'm wondering what i did wrong. Last time this happend was then i tried to save on PlayerRemoving. it couldn't save because the game was shutting down before the function even began executing. But this script saves 3 values when a TextButton is clicked.
LocalScript on PlayerGui:
local RE = game.ReplicatedStorage:WaitForChild("SettingsPromptSave") script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Parent.PromptMenu.Visible = false RE:FireServer(game.ReplicatedStorage.Theme.Value, game.ReplicatedStorage.Wallpaper.Value) print("Event Fired") end)
DataSaveScript on ServerScriptService:
dss = game:GetService("DataStoreService"):GetDataStore("FirstJoin2") dsstheme = game:GetService("DataStoreService"):GetDataStore("SettingsThemeSave2") dsswallpaper = game:GetService("DataStoreService"):GetDataStore("SettingsWallpaperSave2") game.ReplicatedStorage.SettingsPromptSave.OnServerEvent:Connect(function(player, theme, wallpaper) local saved, failed = pcall(function() dss:SetAsync(player.UserId, true) dsstheme:SetAsync(player.UserId, theme) dsswallpaper:SetAsync(player.UserId, wallpaper) end) if saved then print("First time loign is false") else warn(failed) end end)
DataLoaderScript on ServerScriptService:
dss = game:GetService("DataStoreService"):GetDataStore("FirstJoin2") dsstheme = game:GetService("DataStoreService"):GetDataStore("SettingsThemeSave2") dsswallpaper = game:GetService("DataStoreService"):GetDataStore("SettingsWallpaperSave2") game.Players.PlayerAdded:Connect(function(player) local playergui = game.ReplicatedStorage local set, failed = pcall(function() playergui.LoginBefore.Value = dss:GetAsync(player.userId) playergui.Theme.Value = dsstheme:GetAsync(player.userId) playergui.Wallpaper.Value = dsswallpaper:GetAsync(player.userId) wait(1) end) if set then print("Values Set") else warn(failed) end end)