Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I check if a player already touched a part?

I'm making a voting system where you step on a pad and when you step on it it says you voted around 300 times. How can I make a check system so it only registers 1 vote.

Here is the code:

local votepad1 = game.Workspace.VotePad1
local votepad2 = game.Workspace.VotePad2
local votepad3 = game.Workspace.VotePad3

local playersWhoHaveVoted = {}

local game1votes = 0
local game2votes = 0
local game3votes = 0

local votingTakingPlace = true

while votingTakingPlace == true do
	wait(0.001)
	votepad1.Touched:Connect(function(part)
		if part.Parent:FindFirstChild("Humanoid") then
		end
	end)
	
end

2 comments

0

what scrip is this local script? script? Where is the script located?

0

It's a normal script in ServerScriptService.

1 answer

You can use a debounce which you have already in there:

local votepad1 = game.Workspace.VotePad1
local votepad2 = game.Workspace.VotePad2
local votepad3 = game.Workspace.VotePad3

local playersWhoHaveVoted = {}

local game1votes = 0
local game2votes = 0
local game3votes = 0

local votingTakingPlace = true

while votingTakingPlace == true do
    wait(0.001)
    votingTakingPlace = false
    votepad1.Touched:Connect(function(part)
        if part.Parent:FindFirstChild("Humanoid") then
        end
    end)
end

2 comments

0

Yes but how do I check the list of names if a player that touched it is already in that list?

0

You can use part.Parent.Name to find the name of the player.

This discussion is preserved as it was. New answers, comments, and votes are closed.