I’m sorry w h a t, that’s not a valid function of the Players service
game.Players.PlayerAdded:Connect(function(plr)
local banStatus = DataStore:GetAsync("bans_"..plr.UserId)
if banStatus then
plr:Kick("You have been banned.")
end
end)
game.ReplicatedStorage.BanTesting.OnServerEvent:Connect(function(player, userid) -- Presuming this is a userid
print(userid)
DataStore:SetAsync("bans_"..tostring(userid), true)
end)
Also there are a couple of mistypo/capitalization errors
plr.UserId returns back a string value, no need to convert it into a string
game.Players.PlayerAdded:Connect(function(plr)
local banStatus = DataStore:GetAsync("bans_"..plr.UserId)
if banStatus then
plr:Kick("You have been banned.")
end
end)
game.ReplicatedStorage.BanTesting.OnServerEvent:Connect(function(player, playerName)
local banTarget = game.Players:FindFirstChild(playerName)
local userid = banTarget.UserId
print(userid)
DataStore:SetAsync("bans_"..userid, true)
end)
Side note, you should check if there’s at least a valid banTarget in the game, otherwise it’ll return back as nil if the Player enters a incorrect name
game.Players.PlayerAdded:Connect(function(plr)
local banStatus = DataStore:GetAsync("bans_"..plr.UserId)
if banStatus then
plr:Kick("You have been banned.")
end
end)
game.ReplicatedStorage.BanTesting.OnServerEvent:Connect(function(player, playerName)
local banTarget = game.Players:FindFirstChild(playerName)
print(banTarget)
if banTarget then
local userid = banTarget.UserId
print(userid)
DataStore:SetAsync("bans_"..userid, true)
end
end)