I have the following table:
BannedPeople = {"PlaceRebuster","BuilderProAwensome","SomeoneElse"--[[More players ahead]]}
From what i've known about DataStores
is that it only saves values for players and not server.
Everytime there's new players entering the table, but when I leave, the new values vanish.
Any idea on how I can save this table on the server?
I would really appreciate!
Datastores are not limited to just players. In fact, you can make the key of a datastore any string you want. However in this case, I would make a data store wherein the keys are player ids (don't use player names!) and the values are bools indicating whether or not the player is banned.
local DataStoreService = game:GetService("DataStoreService") local BannedPlayersStore = DataStoreService:GetDataStore("GameData") function banPlayer (id) local success , errorMsg = pcall(function() BannedPlayersStore:SetAsync(tostring(id) , true) end) if not success then warn("Failed on SetAsync(.."id.." , true) to BannedPlayersStore") warn(errorMsg) end end function removeBanFromPlayer (id) local success , errorMsg = pcall(function() BannedPlayersStore:SetAsync(tostring(id) , false) end) if not success then warn("Failed on SetAsync(.."id.." , false) to BannedPlayersStore") warn(errorMsg) end end function isBanned (id) local success , banned = pcall(function() return BannedPlayersStore:GetAsync(tostring(id)) end) if not success then warn("Failed on GetAsync(.."id..") to BannedPlayersStore") warn(banned) return nil end return banned end game.Players.PlayerAdded:Connect(function(player) if isBanned(player.UserId) then player:Kick("You cannot join because you have been banned.") end end