@Aiden_12114
You could, but if you want to use DataStores for this you would do something as below.
Remember the only reason I’m going the mile typing everything here is that I’ve never created a dataStore for bans myself, otherwise a rough outline’s always more than enough.
-- might lack certain necessity, just pseudo-code
local Players = game:GetService("Players")
local HTTP = game:GetService("HttpService")
local DataStoreService = game:GetService("DataStoreService")
local BansDs = DataStoreService:GetDataStore("BanStore")
local function onPlayerAdded(player)
--// this part would be done somewhere else (adding to the BanList)
--local bannedIds = {451391631; 123134; 1421412;}
--BansDs:SetAsync("Bans",HTTP:JSONEncode(bannedIds))
--//
-- here we get that list, convert it from Json to string
local json = BansDs:GetAsync("Bans")
print(json)
local banList = HTTP:JSONDecode(json)
print(banList[1]) -- would print 451391631
if table.find(banList, player.UserId) then
player:Kick("You are banned")
else
print("welcome to the game")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
For instance, I used the command bar to set the table to the DataStore.
note that JSONEncode is used because tables cannot be saved directly to a DataStore, use JSONEDecode to decode that into it’s original value.
Also when I do BansDs:GetAsync(“Bans”) I get data for a supposed-to-be unique key (here we aren’t saving data for every player, rather saving it impersonally) which is the table in Json format
Yeah it really is obvious, but let’s not forget not everyone is an experienced programmer on the forum!
@ORden_Test1 your second proposed solution doesn’t seem quite right, you can’t index something in a variable through quotes, in your case, just remove the quotes entirely as the value itself is a string.
And btw, the local player’s humanoid’s speed property is not replicated to the server, so this won’t work:
I believe you meant
game:GetService("Players").PlayerAdded:Connect(function(player))
player:Kick("Banned for" .. Reason)
end)
Also note that to concatenate strings, there are 2 dots (…) not an ellipsis(…)
one more thing, when the PlayerAdded event fires the player is passed as a parameter to the anonymous function connected, so you would have to do
Players.PlayerAdded:Connect(function(p)
--// stuff here
end)