The problem with this script is that the data store called “BanForTime” it does not recieve any data i have ran some tests with DataStore Editor everything works fine just the data store listed is there anyway to fix it.
--local err = pcall(function()
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("DataStoreService"):GetDataStore("Bans"):GetAsync(plr.UserId) ~=nil then
plr:Kick(game:GetService("DataStoreService"):GetDataStore("Bans"):GetAsync(plr.UserId))
end
if game:GetService("DataStoreService"):GetDataStore("BanForTime"):GetAsync(plr.UserId) ~=nil then
if game:GetService("DataStoreService"):GetDataStore("BanForTime"):GetAsync(plr.UserId)[1] < tick() then
game:GetService("DataStoreService"):GetDataStore("BanForTime"):RemoveAsync(plr.UserId)
else
plr:Kick(game:GetService("DataStoreService"):GetDataStore("BanForTime"):GetAsync(plr.UserId)[2])
end
end
end)
game.ReplicatedStorage.Ban.OnServerEvent:Connect(function(plr, ban, reason)
game:GetService("DataStoreService"):GetDataStore("Bans"):SetAsync(game.Players:GetUserIdFromNameAsync(ban), reason)
game:GetService("MessagingService"):PublishAsync("Ban", ban)
end)
game:GetService("MessagingService"):SubscribeAsync("Ban", function(plr)
local player = game.Players:FindFirstChild(plr.Data)
if player ~= nil then
player:Kick(game.DataStoreService:GetDataStore("Bans"):GetAsync(game.Players:GetUserIdFromNameAsync(player.Name)))
end
end)
game:GetService("MessagingService"):SubscribeAsync("BanFT", function(plr)
local player = game.Players:FindFirstChild(plr.Data)
if player ~= nil then
print(game:GetService("DataStoreService"):GetDataStore("BanForTime"):GetAsync(player.UserId))
player:Kick(game:GetService("DataStoreService"):GetDataStore("BanForTime"):GetAsync(player.UserId)[2])
end
end)
game:GetService("MessagingService"):SubscribeAsync("Kick", function(plr)
local banned = plr.Data[1]
local reason = plr.Data[2]
print(banned)
print(reason)
if game.Players:FindFirstChild(banned) then
game.Players:FindFirstChild(banned):Kick(reason)
end
end)
game.ReplicatedStorage.Unban.OnServerEvent:Connect(function(plr, unbanned)
game:GetService("DataStoreService"):GetDataStore("Bans"):RemoveAsync(game.Players:GetUserIdFromNameAsync(unbanned))
game:GetService("DataStoreService"):GetDataStore("BanForTime"):RemoveAsync(game.Players:GetUserIdFromNameAsync(unbanned))
end)
game.ReplicatedStorage.TemporaryBan.OnServerEvent:Connect(function(plr, tim, ban, text)
game:GetService("DataStoreService"):GetDataStore("BanForTime"):SetAsync(game.Players:GetUserIdFromNameAsync(ban), {tim, text})
game:GetService("MessagingService"):PublishAsync("BanFT", ban)
end)
game.ReplicatedStorage.Kick.OnServerEvent:Connect(function(plr, ban, reason)
game:GetService("MessagingService"):PublishAsync("Kick", {ban, reason})
end)
--end)