I have a script that is suppose to save the UserId of the player but when I try every time it doesn't work. The kick part works as it kicks the player but if they join another server it does nothing. Can someone tell me how to fix it. Im fairly new to datastores and I don't really get it.
local ds = game:GetService("DataStoreService") local bansave = ds:GetDataStore("Bansaves") local id = {50816673} function checkplayer(player) player.Chatted:connect(function(msg) if string.lower(string.sub(msg,1,4)) == "!ban" then local User = game.Players:FindFirstChild(string.sub(msg,6)).UserId table.insert(id,#id + 1,User) for i,v in pairs(id) do local name = v if player.UserId == name then player:kick("[Reason]You have been caught exploiting. [Ban Time]: Forever. You may appeal if you like") bansave:SetAsync("id", id) end end end end) while true do wait() for value in ipairs(id) do local name = value if player.UserId == name then player:kick("[Reason]You have been caught exploiting. [Ban Time]: Forever. You may appeal if you like") end end end end game.Players.PlayerAdded:Connect(checkplayer)