RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a script that will save each players that are a member of a clan that uses bool value"
-- server script local DataStoreService = game:GetService("DataStoreService") local clanDataStore = DataStoreService:GetDataStore("ClanMembers") game.Players.PlayerAdded:Connect(function(player) local userId = tostring(player.UserId) local success, isMember = pcall(function() return clanDataStore:GetAsync(userId) end) if success and isMember then player:SetAttribute("IsClanMember", true) else player:SetAttribute("IsClanMember", false) end end) game.Players.PlayerRemoving:Connect(function(player) local userId = tostring(player.UserId) local isMember = player:GetAttribute("IsClanMember") local success, err = pcall(function() clanDataStore:SetAsync(userId, isMember) end) if not success then warn("Failed to save clan member data for user " .. userId .. ": " .. err) end end)