RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a datastore that saves a Bool value called Knight inside the player"
-- server script local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("MyDataStore") game.Players.PlayerAdded:Connect(function(player) local success, data = pcall(function() return myDataStore:GetAsync(player.UserId .. "-Knight") end) if success then if data == nil then player.Knight.Value = false else player.Knight.Value = data end else warn("Failed to load data for player: " .. player.Name) end end) game.Players.PlayerRemoving:Connect(function(player) local success, err = pcall(function() myDataStore:SetAsync(player.UserId .. "-Knight", player.Knight.Value) end) if not success then warn("Failed to save data for player: " .. player.Name) end end)