I fount a bug and I am in the process of fixing it.
THE BUG HAS BEEN RESOLVED ENJOY YOUR VOTING MODULE NOW~
Edit: I am hoping to rewrite this from scratch with a better API. I will do it once I have time.
EDIT: NUMBEROFVOTES THING HAS BEEN ADDED GO CHECK THE VOTING GAME TO TEST
EDIT: MODULE IS NOW OPEN SOURCE DUE TO PRIVATE MODULES NOT WORKING ANYMORE
This module is under the license you can use my module for commercial purposes for free but not redistribute the source code.
Before we talk let me say this: This is a general-purpose voting module if you feel it is not I think I might have explained it wrong so please say something in the dev forum reply in this thread.
Hello, guys! I decided to make a better voting module and also make better documentation, so here I present Voting Module v2! Before let me explain the difference to the one. This VotingModule disconnects the event when you call VotingModule.EndVoting! So basically it is more efficient since it automatically disconnects events for you when you call a function. Also, I removed and added some new functions. Most importantly, I made a big change to the parameters! Before you had to specify parameters again and again, but now you know what you can do?!
FruitVoting = VotingModule.StartVoting(3,game.ServerStorage.Fruits, game.ServerStorage.VotingSystem.VotingFruitPads) SportVoting = VotingModule.StartVoting(2,game.ServerStorage.Sports, game.ServerStorage.VotingSystem.VotingSportsPads)
Yep, now it’s better! The StartFunction returns a table and the module uses that table sent as an argument for its parameters if your wondering!
Anyways let’s get to the juicy part the documentation and the testing game.
Testing game link, also you can view its code in Roblox studio.
NumberOfVoting Options is the number of voting choices that will be presented to the player
FolderWithAllVoteOptions is the folder with all the voting choices.
For example, if we were talking about maps it would be the folder with all the game’s maps!
In the case of Maps, it would store the Maps which will be used this round for voting.
We do not want to overwhelm the player with too many choices so we give him/her a certain amount of choices.
The Map’s info folder is where its image is located
That Image texture will be copied to the votingPad’s Essential.ImagePart.Image.Texture
VotePadsFolder is the VotePads you want to use which will correspond with the voting choices
The VotePadsFolder should contain the number of voting options declared by NumberOfVotingOptions
Remember you can set up multiple voting pads and have how many choices you want!
This function also makes the votepads presented as the argument inside the workspace to put the voting room to after this or before it uses the function VotingModule.DisplayVotingRoom()!
VotingModule.StartVoting returns a table of parameters passed in which can be used for other functions as the argument.
Alright StartVoting activates the touched events for the pads, basically activates voting
Also, it fires a remote event called VotingHandler in replicated storage with two pieces of info the votepad touched and the folder with votepads, I use this to make the pad green when touched in the voting test game. It fires it to the player who touched it.
For the ones below use the value returned by StartVoting as those function’s parameters, do this for everything except CleanUpVoting and the other two extra functions, DisplayVotingRoom and StoreVotingRoom() these take no arguments
Returns the choice with most votes at the present moment
It ends voting disconnecting touched events
Stores the votepads folder inside the voting system in server storage again.
Removes all the values created in the player and etc by the voting system, PLEASE USE THIS after every voting cycle
The other Functions:
Makes the voting room model or folder in the VotingSystem folder in the server storage parented to the workspace. If you don’t have a voting room don’t use this because it will error obviously. In the test game, we have this.
same goes with:
This parents it back to the folder VotingSystem in server storage
If you have any questions please ask me also any bugs please report them. Also if the voting module loader isn’t working in your game please say so, also give feedback. Also, Some things planned out is for the remote event fired in VotingModule.StartVoting I am going to include a voting state variable for further control for developers. And most importantly have fun!