I want to create a vote map but when player touching "vote button", yes it working but, it repeat. Through this method player can make 99999999 votes.
a = 0 local function one(hit) if hit and hit.Parent:FindFirstChild("Humanoid") then a = a + 1 print(a) end end script.Parent.Touched:Connect(one)
I newbie and I want to know how to one time use.
If it truly is a one-time use, you can simply store the players' names in a table after they touch the part. Then, everytime a touch occurs, simply check to see if their name is in the table before applying the vote.
In a Server Script:
local Voters = {} local a = 0 script.Parent.Touched:Connect(function(part) local Player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent) if Player then --ensure it is a player touching for i,v in pairs(Voters) do --loop through to find a matching name if v ~= Player.Name then --if not, add vote table.insert(Voters,Player.Name) a = a + 1 end end if #Voters == 0 then --this is necessary, because the for loop above will not run if there are 0 entries table.insert(Voters,Player.Name) a = a + 1 end end end)