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

How can I check if a player has clicked a click detector before?

I have a button that enters a players vote and only want them to vote once, I'm tried using datastores but to no avail. Any help is appreciated.

1 answer

✓ Accepted answer

It's better to use a table for this:

local playersWhoVoted = {}

ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	if not playersWhoVoted[playerWhoClicked] then
		playersWhoVoted[playerWhoClicked] = true
	else
		return
	end
end)

I'm not sure what you want to do exactly, maybe you want players to only vote for one map and then you also want to tally the votes. I'm not going to answer how to do those because they're beyond the scope of the question.

7 comments

0

Thank you so much!

0

Make sure to accept my answer if it works.

0

Just one question, how would i append something to that table(playerwhovoted)

0

Doing table[key] = value creates an element in the table with key and value. Line 5 creates an entry to playersWhoVoted with the playerWhoClicked being the heading and 'true' being the value of that heading.

0

Ok! thanks, also there is no accept answer button?

0

It should at the bottom of my answer, right next to the report button.

0

i think its because of my browser, let me change it rq

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