Hey, community!
I made this easy-to-use spill system for newly created cafes or whoever needs it if you don’t feel like making your own. It comes with a settings module to quickly edit the critical things in the system. It didn’t take me long, and the code is kind of messy, so please forgive me.
Notes:
This system does require you to do a few crucial things to work correctly, but they will all be inside the model; you will have to parent some stuff. The way spills spawn, the script randomly picks an area (a part) inside a folder, and it obtains a random CFrame inside of that part to generate the spill in that area. If you want to change the distance needed to clean a spill, you can change the MaxActivationDistance property inside of the ClickDetector, as it goes off of that.
Changelog (1/7/2022):
-
Added a DataStore system to save player currency easily.
-
Added a new setting inside of RewardSettings called DefaultValue; if the datastore can’t find player data, their points will be set as the amount.
-
New setting called DataStoreSettings:
- DataStoreEnabled - By default, it will create a datastore for the currency. Ex. Points
- DataStoreName - Changing this will reset the datastore value.
- CreateStats - By default, this will create the stats found in RewardSettings
-
NOTE: To use the new system, you will need to redownload the model, or just copy and paste the new SpillHandler code into your old one.
Changelog (1/3/2022):
-
Converted to a module, so you don’t have to get the new model each time changes are made.
-
Added an “IsSpecial” value inside the tool configuration; used for bypassing the clean time when someone else stops cleaning the spill—used for Golden Mops and such.
-
Made it so if they unequip their tool midway through cleaning, it stops cleaning, and anyone can finish cleaning the spill.
-
New setting inside of SpillSettings called “DeleteOnUnequip” allows you to choose if spills should be deleted when a player unequips their tool.
-
Updated the LocalScript, so all you have to do is insert the one into StarterPlayerScripts, and it’ll work for all your tools.
Instructions:
-
Insert the “SpillFolder” into the workspace; there is a folder named “SpillFolder” inside the model that should be inserted into the workspace, which has two folders inside it. You can clone the part inside the “Areas” folder to make multiple areas.
-
Place the “Events” folder into ReplicatedStorage.
-
Place the “SpillHandler” script into ServerScriptService.
-
Place the LocalScript (ClientClick) into StarterPlayerScripts, and all you have to do is make sure whatever tool you’re using is inside of the ToolsName section of the settings. You can watch the installation video below to learn how to add more tools if you don’t know-how.
Now, everything will work like that, but you most likely want to make a few customizations, so let’s get into that!
Configuring the main script:
You’ll see a few things that you can modify; I’ll try to go over the one most might want to edit.
-
DataStoreSettings
- DataStoreEnabled - By default, it will create a datastore for the currency. Ex. Points
- DataStoreName - Changing this will reset the datastore value.
- CreateStats - By default, this will create the stats found in RewardSettings
-
Group Configuration
-
GroupId; if you want to make this system only work for those of a certain rank in your group, you want to use this. Instead of having the value as nil, you need to insert whomever group you want to use id there. Leaving the value as nil will allow everyone to clean spills.
-
GroupRank; this is the rank that is allowed to clean spills (you can find this in your group settings.)
-
-
SpillSettings
- MaxSpawnedAllowed; is the max amount of spills that are allowed to be spawned at once.
- SpawnWaitTime; whatever the value is set to, spills will spawn every time elapsed.
- PathToSpill; if the spill isn’t in the default folder, change this to the spill’s path.
- DeleteOnUnequip; if true, the spill will delete if the player is cleaning it and unequips their tool.
-
RewardSettings
-
FolderName; the default value is set to “leaderstats” as that is where most store their points value. You may change it to the folder’s name where the value is. Please note, whatever this is set to, the script will search the player for the folder, so if your folder is inside of another folder, that will not work right now as I didn’t add it.
-
StatName; the default value is set to “Points” but can be changed to whatever. It will not work if this value is not found inside the folder given in the FolderName setting.
-
DefaultReward; the default amount which should be rewarded when cleaning a spill.
-
-
ToolNames
- Inside of here should be tables that should store the tool’s name, the multiplier (like Golden Mops), and the clean duration. I’ve left examples in the script for further help.
Changing the spill
Changing the spill is quite simple; make sure you insert the ClickDetector, and the BillboardGui (CleaningProgress) found inside the default spill into the main one and, of course, change the PathToSpill settings if you changed the path or name.
Get the model
I think I’ve covered all of the things this model requires, but if you need any further assistance, you are more than welcome to message me on the DevForum. If you found any bugs or anything related to that, you can also message me on the DevForum or post a reply so that I can fix them.
You can get the model here: https://www.roblox.com/library/8437454042/Spill-System-V1-0-0
Source Code: https://www.roblox.com/library/8444816967/Spill-Handler-V1-Source
Installation Instructions: