Hiya! I’m glitchifyed and I’ve made this sandbox tycoon placement module for those who don’t want to modify Tunicus’ original placement module themselves.
This module works great for sandbox tycoons, which is a genre which originated from the hit tycoon game, Miner’s Haven! The Miner’s Haven open source has a placement module that behaves very similarly to this one.
Please be aware this is an updated version of Tunicus’ placement module that he made open source back in 2017. It has been ‘modernised’ with more features, such as:
Here are the modifications I have made to the module:
- Objects with customisable adjustable heights (hydraulics)
- Objects that can be placed on top of (platforms)
- You can place on top of multiple of these platforms at once
- Hydraulic items can have legs that automatically size themselves to stand on the ground
- The grid texture now has an option to fade in/out and has a custom colour
- There are customisable SelectionBoxes that will go on any item you’re currently placing and obstacles while you’re placing
- A setting to hold the place button down to continue placing
- An option to stop items from wobbling around when moving the mouse while placing
- An option to hide CoreGui while placing
- Easily customisable keybinds that also support Xbox controls
Settings:
// PLACEMENT SETTINGS
bool INTERPOLATION -- whether placement smoothing is enabled
bool WOBBLE_ITEMS -- whether items wobble when moving (does nothing if interpolation is false)
float INTERPOLATION_DAMP -- how fast smoothing is, make it a value [0, 1]
float ROTATION_SPEED -- rotation tween speed in seconds
float PLACEMENT_COOLDOWN -- how quickly the user can place (minimum time in seconds between placing items)
bool HOLD_TO_PLACE -- if the user can hold the place key to place
bool HYDRAULICS_ENABLED -- whether hydraulics can be utilised or not
bool PLATFORMS_ENABLED -- whether platforms can be utilised or not
float PLATFORM_SIZE -- the y size of platform parts (used to offset the placement correctly on platforms)
// PLACEMENT COLORS, TRANSPARENCY, FADING
Color3 COLLISION_COLOR3 -- color of the hitbox when object collides
float COLLISION_TRANSPARENCY -- transparency of the hitbox when object collides
Color3 NORMAL_COLOR3 -- color of the hitbox
float NORMAL_TRANSPARENCY -- transparency of the hitbox
Color3 LOAD_COLOR3 -- color of the hitbox when loading
float LOAD_TRANSPARENCY -- transparency of the hitbox when loading
float HIT_BOX_FADE_TIME -- primarypart/selection box fade time in seconds. set to 0 to instantly change/appear
// SELECTION BOXES
float SELECTION_BOX_TRANSPARENCY -- selection box transparency. set to 1 for no selection boxes
Color3 SELECTION_BOX_COLOR3 -- selection box color. set to nil for a custom color system (you have to code that yourself)
float SELECTION_BOX_PLACING_THICKNESS -- selection box thickness on objects the user is placing
float SELECTION_BOX_OBSTACLE_THICKNESS -- selection box thickness on obstacles
// GRID SETTINGS
string GRID_TEXTURE -- texture of the grid space, set to nil if you don't want a visible grid
Color3 GRID_COLOR3 -- color of the grid texture
float GRID_TRANSPARENCY -- the transparency of the grid while placing
float GRID_FADE_TIME -- the amount of seconds that the grid takes to fade. set to 0 to instantly appear
bool TEXTURE_ON_PLATFORMS = true -- if the grid texture is also put on platforms
// CONTROLS
bool OVERRIDE_CONTROLS -- whether the keybinds below work or not
int INPUT_PRIORITY -- input priority of default controls
list PLACE_KEYBINDS -- placement keybinds (pc, xbox)
list ROTATE_KEYBINDS -- rotate keybinds (pc, xbox)
list HYDRAULIC_UP_KEYBINDS -- hydraulic up keybinds (pc, xbox)
list HYDRAULIC_DOWN_KEYBINDS -- hydraulic down keybinds (pc, xbox)
list CANCEL_KEYBINDS -- cancel placement keybinds (pc, xbox)
// CORE GUI
list CORE_GUI_DISABLE -- core gui to disable when placing
Basic example:
LocalScript inside a TextButton
local placement = require(game.ReplicatedStorage.placement)
local plane = placement.new(workspace.Base, workspace.Obstacles, 3)
local placing = false
local clone: Model
script.Parent.MouseButton1Click:Connect(function()
if (placing) then
placing = false
plane:disable()
clone:Destroy()
return
end
placing = true
clone = game.ReplicatedStorage.Model:Clone()
plane:enable(clone, workspace.Temporary, false)
end)
Some more detailed pseudocode can be found directly within the module itself, including code that runs on the server. Server collision verification code can also be found on GitHub.
How to use hydralics & platforms:
To utilise hydraulic item placements, you can add a ‘minHeight’ attribute and ‘maxHeight’ attribute (both numbers) to allow for vertical placements above/below other items. These measurements range in units based on whatever grid size you provide the module when creating the plane.
The ‘height’ attribute can also be used to provide a default height for an item when enabling placement mode.
Platform items simply require a Part named ‘platform’ to be located as a child of the item model. These platform parts can then support models being placed on top of them.
License:
This module is under the MIT license which means you are allowed to freely use this for commericial and private use, modify it, and distribute it as you please.
Credits/attributions:
You don’t have to credit I or Tunicus, but credit would be greatly appreciated. We both put many many hours into this just to give it away to the community for free.
Also, here’s the link to the original module that I’ve modified: Placement Handler V2
Possibilities for the future:
- More in-depth text-tutorial on how to use this module
- Video tutorial on how to use the module
You can add the module to your inventory here:
Roblox module (doesn’t have server-sided placement protection)
You may use this test place to see how the module works:
Github page (rbxl place file with server-sided placement protection)
Also, the module script itself doesn’t handle the actual placement of the models, only the placement preview of the models. I have however provided a .rbxl file in the Github that contains an example of server-sided placement code that does actually place the models down.
I have also made a module that allows you to calculate numbers past the limits of Roblox numbers. If you are interested, see this post on the Dev Forum here: UltiNum v1.0 Extended Number Module
July 2024 status update:
I have been at work creating the next iteration of this module. This new module is going to take some time, but it’s already at a great start! It’s going to feature improved platform placement, optimised collision detection, more settings, and even multi-hitbox placement!
Multi-hitbox placement will allow you to specify multiple hitboxes inside a single item, which can prove incredibly useful!
Disclaimer: This new module is going to be a lot more difficult to use in a project, due to the very nature of how I’m writing it. It is not made to handhold people, but rather it’s going to be more for power-users who want to customise the placement visuals and such withouit having to directly modify the module. This includes the hitbox visuals, leaving displaying collisions between items entirely up to the developer!
The new module will still continue to pivot the models during placement and smooth them, with all-new smoothing types such as elasticity!
I will personally make sure it is as accessible as possible, so much so that I am planning on providing even VR devices a great experience.