Hi, I am making a map voting system, and I want the player to able to vote between the voting pads without any limit. The problem is is that it only lets the player vote once and doesn’t switch between the voting pads. Can someone help? Here is my current code:
local voters = {}
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if table.find(voters,plr) then --if it finds player in table then
if plr.Character:FindFirstChild("VotingTag").Value ~= script.Parent.Name then --if the value isnt this pad
local t = plr.Character:FindFirstChild("VotingTag")
local find = workspace.Lobby:FindFirstChild(t.Value)
local n = tonumber(find.SurfaceGui.TextLabel.Text)-1
find.SurfaceGui.TextLabel.Text = tostring(n)
t.Value = script.Parent.Name
local new = tonumber(script.Parent.SurfaceGui.TextLabel.Text)+1
script.Parent.SurfaceGui.TextLabel.Text = tostring(new)
table.insert(voters,plr)
end
elseif not plr.Character:FindFirstChild("VotingTag") or not table.find(voters,plr) then
local tag = Instance.new("StringValue")
tag.Name = "VotingTag"
tag.Value = script.Parent.Name
tag.Parent = plr.Character
local new = tonumber(script.Parent.SurfaceGui.TextLabel.Text)+1
script.Parent.SurfaceGui.TextLabel.Text = tostring(new)
table.insert(voters,plr)
end
end
end)