im currently working on a votekick, but for some reason it only adds to the vote value every second vote
for index = 1, #KickDictionary do
local TempVal = tostring(KickDictionary[index])
print (TempVal)
if TempVal == message[2] then
Votes = Votes + 1
end
end
im really out of options here as to why it would only add to every second time it is called…
This is the whole script
Banlist = {}
KickDictionary = {}
function Clean(player, message)
if message:sub(1,9):lower() == "votekick/" then
message = message:split("/")
local Votes = 0
local VotedAlready = false
local ValidPlayer = false
for _, instance in ipairs(game.Players:GetPlayers()) do
if message[2] == instance.Name then
ValidPlayer = true
end
end
if ValidPlayer == true then
for index = 1, #KickDictionary do
if not KickDictionary[index] then
if player.Name == KickDictionary[index] then
if message[2] == KickDictionary[player.Name] then
print(player.Name.." already voted to kick "..message[2])
VotedAlready = true
elseif message[2] ~= KickDictionary[player.Name] then
KickDictionary[player.Name] = message[2]
print(player.Name.." voted to kick "..message[2])
print(KickDictionary[index])
end
end
end
end
if VotedAlready == false then
KickDictionary[#KickDictionary + 1] = player.Name
KickDictionary[player.Name] = message[2]
print(unpack(KickDictionary))
end
for index = 1, #KickDictionary do
local TempVal = tostring(KickDictionary[index])
print (TempVal)
if TempVal == message[2] then
Votes = Votes + 1
end
end
if Votes >= MinVotes then
local TempVal = #Banlist + 1
Banlist[TempVal] = message[2]
local Plr = game.Players:WaitForChild(tostring(message[2]))
Plr:kick("you are kicked")
end
print(Votes, MinVotes)
elseif ValidPlayer == false then
print(player.Name.." tried kicking "..message[2].." which isnt here")
end
end
end
function AddMinVotes(player)
for index = 1, #Banlist do
if Banlist[index] == player.Name then
player:Kick("Youre kicked")
end
end
MinVotes = 0
for _, instance in ipairs (game.Players:GetPlayers()) do
MinVotes = MinVotes + .5
end
player.Chatted:Connect(function (message)
Clean(player, message)
end)
end
function SubtractMinVotes(player)
for index = 1, #KickDictionary do
if KickDictionary[index] == player.Name then
table.remove(KickDictionary, index)
end
end
MinVotes = 0
for _, instance in ipairs (game.Players:GetPlayers()) do
MinVotes = MinVotes + .5
end
end
game.Players.PlayerAdded:Connect(AddMinVotes)
game.Players.PlayerRemoving:Connect(SubtractMinVotes)