Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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.

0
Thank you so much! archipelxgo 7 — 2y
0
Make sure to accept my answer if it works. radiant_Light203 1166 — 2y
0
Just one question, how would i append something to that table(playerwhovoted) archipelxgo 7 — 2y
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. radiant_Light203 1166 — 2y
View all comments (3 more)
0
Ok! thanks, also there is no accept answer button? archipelxgo 7 — 2y
0
It should at the bottom of my answer, right next to the report button. radiant_Light203 1166 — 2y
0
i think its because of my browser, let me change it rq archipelxgo 7 — 2y
Ad

Answer this question