Voting Module v2

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

https://www.roblox.com/library/4985345430/Voting-Module-v2

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)

VotingModule.EndVoting(SportVoting)
VotingModule.EndVoting(FruitVoting)

VotingModule.StoreVoting(SportVoting)
VotingModule.StoreVoting(FruitVoting)

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.

https://www.roblox.com/games/4990285664/Voting-Test

Documentation:

VotingModule.SetupVoting(NumberOfVotingOptions,FolderWithAllVoteOptions,VotePadsFolder)

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

VotingModule.VoteChoosingFunction()

Returns the choice with most votes at the present moment

VotingModule.EndVoting()

returns nothing

It ends voting disconnecting touched events

VotingModule.StoreVoting()

Stores the votepads folder inside the voting system in server storage again.

VotingModule.CleanUpVoting()

Removes all the values created in the player and etc by the voting system, PLEASE USE THIS after every voting cycle

The other Functions:

VotingModule.DisplayVotingRoom()

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:

VotingModule.StoreVotingRoom()

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!

19 Likes

Nice module! Im working on a game, and I might change my current voting system to this one, thanks!

Oh thanks, if the module does not work because I required a private one from a public one just message me here and I will give the source code of the module privately!

1 Like

If you’re releasing it here to us, then why not just make it open source? How are you even requiring a private module? I thought that was disabled?

I don’t know my friend said it would work, also I really dont want to give the source code I hope you understand! if you have any ways to hide the module if this way doesn’t work please tell me on Pm’s!

I just tried requiring it in my own studio and it returned an error. I don’t think it’s possible to load private modules anymore.

1 Like

yes, I think Its the problem with the private module thing can you PM me for the source code

Can I also have the source? I wanna put this.

Great module!

But considering you have documentation in your post, I’d recommend designing it a bit.

I recommend this formatting guide.

Alright thanks! From next time on I will use this.

Yah now the module is open source but kinda has a licence

This module is under the license you can use my module for commercial purposes for free but not redistribute the source code.

Source code is now open the module link

https://www.roblox.com/library/4985345430/Voting-Module-v2

1 Like

I fixed the bug now there should be no problems!

1 Like

NUMBEROFVOTES PART HAS BEEN ADDED GO CHECK THE VOTING GAME TO TEST, now you can add more functionality check the game to see how the things have to be named, for it to work. basically put a part named NumberOfVotes inside essential folder, then put a surface gui called NumberOfVotesGui and inside that part then put a textlabel and keep it at the default name. if you dont want this functionality just dont add a part called NumberOfVotes in the esential folder

I thought I would add an update sorry for ghosting for a long time, basically the point is i’m no longer making community resources I only make modules for my inhouse collection. Which I use for my projects or whatever.

If anyone still wants this I can make a more flexible module which doesn’t just support touched events by utilizing the power of callbacks.

2 Likes