VoteFolder = Instance.new("Folder", game.ServerStorage)
VoteFolder.Name = "VoteFolder"
game.Players.PlayerAdded:Connect(function(Plr)
print(Plr.Name.." joined the game.")
local Votes = Instance.new("IntValue",VoteFolder)
Votes.Name = Plr.Name
end)
game.Players.PlayerRemoving:Connect(function(Plr)
print(Plr.Name.." left the game.")
VoteFolder:FindFirstChild(Plr.Name):Destroy()
end)
function CheckPlayerExistance(Player)
if game.Players:FindFirstChild(Player)
then
local ExistPlayer = game.Players:FindFirstChild(Player)
return ExistPlayer
else
print(Player.." is not a Player/Not in the game.")
end
end
function CheckIfPlayerAlive(Player)
if Player.Team ~= "Dead"
then
return Player
else
print(Player.Name.." is Dead.")
end
end
function VotePlayer(VotedPlayer)
VoteFolder:FindFirstChild(VotedPlayer.Name).Value = VoteFolder:FindFirstChild(VotedPlayer.Name).Value+1
end
game.ReplicatedStorage.Remotes.PlayerVoted.OnServerEvent:Connect(function(plr, ChosenPlayer)
if plr.Team ~= "Dead"
then
VotePlayer(CheckIfPlayerAlive(CheckPlayerExistance(ChosenPlayer)))
end
end)
while true
do
for _,Votes in pairs(VoteFolder:GetChildren())
do
game.ReplicatedStorage.Remotes.DisplayVotedPlayers:FireAllClients(Votes.Name, Votes.Value)
end
wait(0.1)
end
This code detects whenever one of many buttons is clicked. However, when one of the button is destroyed by using:
game.Players.PlayerRemoving:Connect(function(plr)
local Button = Frame2:FindFirstChild(plr.Name)
Button:Destroy()
end)
The buttons don't detect clicks anymore. What is the issue? Thanks in advance, KochbananemitGuave

2 comments
In the first script, use Connect. 'connect' is deprecated.
I need to see more of your code. When are you running the for loop to setup the click events?