I was working on a votekick system, but for some reason when I try it with multiple players, it doesnt send an error, yet does nothing, heres my script:
local adminList = {} --Players that can instantly votekick.
local prefix = "!" --If the message the player sent starts with this, it means that they want to send a command
local function getPlayerFromPartialName(PartialName)
local foundName = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local PossiblePlayer = Players[i]
if string.find(string.lower(PossiblePlayer.Name), string.lower(PartialName)) then
foundName = PossiblePlayer
end
end
if not foundName then
return nil
else
return foundName
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(command)
if game.ReplicatedStorage.VotekickValues.VotekickInProgress == false then
local msg = command:lower()
local targetSplit = msg:split(" ")
local cmd = targetSplit[1]
local target = targetSplit[2]
if target == nil or cmd == nil then
print("returned")
return nil
else
print("continued")
end
print(cmd)
print(target)
local prefixCut = cmd:split(prefix)
print(prefixCut[2])
if prefixCut[2] == "votekick" then
print("worked")
else
print("command wasnt initiated")
return
end
local target = getPlayerFromPartialName(target)
print(target)
if target then
print(true)
else
print(false)
return
end
print(target)
print(target.Name)
local votes = 1
local requiredVotes = math.round(math.min(1,#game.Players:GetPlayers() * .65))
for i,v in pairs(game.Players:GetPlayers()) do
local gui = v.PlayerGui:FindFirstChild("VotekickGui")
gui.Enabled = true
if not gui or v == target then
gui.Enabled = false
end
gui.Frame.TextLabel.Text = "A votekick was initiated for "..target.DisplayName.." (@"..target.Name..")"
local votecasted = false
local yes = gui.Frame:WaitForChild("Yes")
local no = gui.Frame:WaitForChild("No")
yes.MouseButton1Up:Connect(function()
if votecasted == false then
votes += 1
gui.Enabled = false
votecasted = true
end
end)
no.MouseButton1Up:Connect(function()
gui.Enabled = false
end)
end
task.wait(5)
if votes >= requiredVotes then
target:Kick()
end
end
end)
end)
Help is appriciated!
Edit: Heres the explorer: