Voting Skip Gui stopped working after the first wave of the game

currently making a TD game. So i tried to make a Skip System where the player can choose to skip or not. First wave seem working pretty well it does skip the wave 1 to wave 2 but after that the Gui seem stopped working i cant vote or anything anymore.
local script:

local ToggleVoteEvent = game.ReplicatedStorage.Events.ToggleVote
local AddVoteEvent = game.ReplicatedStorage.Events.AddVote
local HasVoted = false

local Frame = script.Parent
local Button1 = Frame.Check
local Button2 = Frame.Close

local Option1 = game.ReplicatedStorage.VoteValue.Option1
local Option2 = game.ReplicatedStorage.VoteValue.Option2

ToggleVoteEvent.OnClientEvent:Connect(function(Value)
	if Value == true then
		Frame.Visible = true
	elseif Value == false then
		Frame.Visible = false
	end
end)

local function Vote(Button, Option)
	if HasVoted == false then
		HasVoted = true
		AddVoteEvent:FireServer(Option)
	end
end

Button1.MouseButton1Click:Connect(function()
	Vote(Button1, 1)
end)

Button2.MouseButton1Click:Connect(function()
	Vote(Button2, 2)
end)

Option1.Changed:Connect(function()
	Button1.Count.Text = Option1.Value
end)

Option2.Changed:Connect(function()
	Button2.Count.Text = Option2.Value
end)

Main Vote Sever Script:

local AddVoteEvent = game.ReplicatedStorage.Events.AddVote
local ResetVoteEvent = game.ReplicatedStorage.Events.ResetVote
local Option1 = game.ReplicatedStorage.VoteValue.Option1
local Option2 = game.ReplicatedStorage.VoteValue.Option2

AddVoteEvent.OnServerEvent:Connect(function(Player, Option)
	if Option == 1 then
		Option1.Value += 1
	elseif Option == 2 then
		Option2.Value += 1
	end
end)

ResetVoteEvent.Event:Connect(function(Option)
	if Option == 1 then
		Option1.Value = 0
	elseif Option == 2 then
		Option2.Value = 0
	end
	return
end)

Main Wave Sever Script:

for wave=1, 10 do
	info.Wave.Value = wave
	info.Message.Value = ""
	round.GetWave(wave, map)
	task.wait(1)
	ResetVoteEvent:Fire(1)
	ResetVoteEvent:Fire(2)
	ToggleVoteEvent:FireAllClients(true)
	repeat
		task.wait(1)
		print(Time)
		info.Skip.Value = false
		Skip = false
		NextWave = false
		if Time == 0 or Skip == true or #workspace.Mobs:GetChildren() == 0  then
			info.Skip.Value = true
			Skip = true
			NextWave = true
		elseif Option1.Value > Option2.Value  then
			info.Skip.Value = true
			Skip = true
			NextWave = true
		elseif Option1.Value < Option2.Value then
			info.Skip.Value = false
			Skip = false
			NextWave = false
			Time -= 1
			info.Time.Value = Time
		elseif Option1.Value == 0 and Option2.Value == 0 then
			info.Skip.Value = false
			Skip = false
			NextWave = false
			Time -= 1
			info.Time.Value = Time
		else
			Time -= 1
			info.Time.Value = Time
			info.Skip.Value = false
			Skip = false
		end	
	until #workspace.Mobs:GetChildren() == 0 or gameOver or Skip == true or NextWave == true or Time == 0 or info.Skip.Value == true

Thanks for reading.

This is probably the reason why it’s not working. Because, you have made a condition that checks to see if not HasVoted… which is here:

In your way of coding it, you have to change it back to false after the voting has finished. Which you could do here (assuming that this is where the value changes the voting system’s visibility):

1 Like

Thanks alot its work now. Didnt even think about that lol

1 Like