How do i check if either one of these parts are touched?

basically im trying to make a voting system that involves these three parts. the circled parts are for the touched functions. i have something going but im trying to detect if either one of these three parts are touched which are stored in a table called voteParts if that makes sense…

script:

local manfacevote = workspace.manfacevote
local catmanfacevote = workspace.catmanfacevote
local shaggymanfacevote = workspace.shaggymanfacevote

local plrName = {}

--parts
local voteParts = {
manpart = workspace.manface,
catpart = workspace.catmanface,
shaggypart = workspace.shaggymanface
}


local vals = 0
local db = false

voteParts.Touched:Connect(function(hit) -- put a table of a list of parts doesnt work (lol mb)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if table.find(plrName, plr.Name) then return end
	if db then return end
	db=true
	vals = vals + 1
	if hit.Parent:FindFirstChild("Humanoid") then
		manfacevote.SurfaceGui.TextLabel.Text = "votes: "..vals

		table.insert(plrName, plr.Name)
		print(plr.Name.." has voted. they can no longer vote again!")
	end
	db = false
end)

Just iterate over them.

for _, part in pairs(voteParts) do
    part.Touched:Connect(yourFunctionHere)
end
1 Like

absolute legend. didn’t know the way to do it. thank u so much bro!!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.