Can you let me know why it doesn’t work? If you need more screenshots I can provide some
P.S There is nothing else in the script obstructing it’s function
P.P.S I know that there is a way I could do this more efficiently but I’m sticking with this
Like i say, Why aren’t you making use of variables. It’s much easier to work with and it also saves us time to read what you are trying to accomplish. And outside of using while true do loops. Use RunService instead.
Yeah I tried that, the debounce doesn’t work and everything inside the if statement happens, also I printed the debounce variable and it started as true the first time but ended up as false even though it kept printing out
Blockquote
while wait() do
script.Parent.VotePad1.SurfaceGui.Votes.Text = "Votes: ".. table.maxn(voted1)
script.Parent.VotePad2.SurfaceGui.Votes.Text = "Votes: ".. table.maxn(voted2)
script.Parent.VotePad1.SurfaceGui.Votes.Text = “”
script.Parent.VotePad1.Value.Value = table.maxn(voted1)
script.Parent.VotePad2.SurfaceGui.Votes.Text = “”
script.Parent.VotePad2.Value.Value = table.maxn(voted2)
if game.ReplicatedStorage.RoundValues.Voting.Value == false and debounce == true then
debounce = false
local randomnumber = math.random(1,maps)
script.Parent.Board1.Map.Value = maps[randomnumber]
script.Parent.Board1.SurfaceGui.Votes.Text = maps[randomnumber]
randomnumber = math.random(1,maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
script.Parent.Board2.SurfaceGui.Votes.Text = maps[randomnumber]
–Making sure all maps are different
repeat
randomnumber = math.random(1,maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
if script.Parent.Board2.Map.Value == script.Parent.Board1.Map.Value then
randomnumber = math.random(1,maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
end
script.Parent.Board1.SurfaceGui.Votes.Text = script.Parent.Board1.Map.Value
script.Parent.Board2.SurfaceGui.Votes.Text = script.Parent.Board2.Map.Value
until script.Parent.Board2.Map.Value ~= script.Parent.Board1.Map.Value
–
if game.ReplicatedStorage.RoundValues.Voting.Value == false then
if script.Parent.VotePad1.Value.Value> script.Parent.VotePad2.Value.Value then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board1.Map.Value
else
if script.Parent.VotePad1.Value.Value < script.Parent.VotePad2.Value.Value then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board2.Map.Value
else
local a = math.random(1,2)
if a == 1 then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board1.Map.Value
else
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board2.Map.Value
end
end
end
end
debounce = true
end
while wait() do
script.Parent.VotePad1.SurfaceGui.Votes.Text = "Votes: ".. table.maxn(voted1)
script.Parent.VotePad2.SurfaceGui.Votes.Text = "Votes: ".. table.maxn(voted2)
script.Parent.VotePad1.SurfaceGui.Votes.Text = ""
script.Parent.VotePad1.Value.Value = table.maxn(voted1)
script.Parent.VotePad2.SurfaceGui.Votes.Text = ""
script.Parent.VotePad2.Value.Value = table.maxn(voted2)
if game.ReplicatedStorage.RoundValues.Voting.Value == false and debounce == true then
debounce = false
local randomnumber = math.random(1,#maps)
script.Parent.Board1.Map.Value = maps[randomnumber]
script.Parent.Board1.SurfaceGui.Votes.Text = maps[randomnumber]
randomnumber = math.random(1,#maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
script.Parent.Board2.SurfaceGui.Votes.Text = maps[randomnumber]
--Making sure all maps are different
repeat
randomnumber = math.random(1,#maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
if script.Parent.Board2.Map.Value == script.Parent.Board1.Map.Value then
randomnumber = math.random(1,#maps)
script.Parent.Board2.Map.Value = maps[randomnumber]
end
script.Parent.Board1.SurfaceGui.Votes.Text = script.Parent.Board1.Map.Value
script.Parent.Board2.SurfaceGui.Votes.Text = script.Parent.Board2.Map.Value
until script.Parent.Board2.Map.Value ~= script.Parent.Board1.Map.Value
--
if game.ReplicatedStorage.RoundValues.Voting.Value == false then
if script.Parent.VotePad1.Value.Value> script.Parent.VotePad2.Value.Value then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board1.Map.Value
else
if script.Parent.VotePad1.Value.Value < script.Parent.VotePad2.Value.Value then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board2.Map.Value
else
local a = math.random(1,2)
if a == 1 then
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board1.Map.Value
else
game.ReplicatedStorage.RoundValues.CurrentMap.Value = script.Parent.Board2.Map.Value
end
end
end
end
debounce = true
end
Maybe i don’t understand what you mean but how does this not work?
local Debounce = false
local RunService = game:GetService("RunService")
function Test()
if not Debounce then
Debounce = true
print(1)
Debounce = false
end
end
RunService.Heartbeat:Connect(Test)