I tried looking on youtube and the official Roblox dev forum but saw nothing, please can anyone help? Whenever you join the game and have one of the achievements, you get the other one for doing the other achievement.
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("playerData")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "AchievementsFolder"
folder.Parent = player
local CloseDoor = Instance.new("BoolValue")
CloseDoor.Name = "CloseDoorAchievement"
CloseDoor.Parent = folder
local powerout =Instance.new("BoolValue")
powerout.Name = "PowerOutAchievement"
powerout.Parent = folder
local data
local success, errormessage = pcall(function()
data = playerData:GetAsync(player.UserId)
end)
if success then
CloseDoor.Value = data
powerout.Value = data
else
CloseDoor.Value = false
powerout.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
playerData:SetAsync(player.UserId,{player.AchievementsFolder:FindFirstChild("CloseDoorAchievement").Value,player.AchievementsFolder:FindFirstChild("PowerOutAchievement").Value})
end)
if success then
print("Data successfully saved!")
else
print("There was an error while saving the data")
warn(errormessage)
end
end)

1 comment
Thank you! This helped.