-- Settings -- Bools local interpolation = true local moveByGrid = true local buildModePlacement = true -- Ints local rotationStep = 90 local maxHeight = 90 -- Numbers/Floats local lerpSpeed = 0.7 -- Other local gridTexture = "" local placement = {} placement.__index = placement local players = game:GetService("Players") local runService = game:GetService("RunService") local player = players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local mouse = player:GetMouse() --Constructor Variables local GRID_SIZE local ITEM_LOCATION local ROTATE_KEY local TERMINATE_KEY -- Activation Variables local object local placedObjects local ot local stackable -- Variables used in calculations local posX local posY local posZ -- Calculates initial y position above an object local function calculateYPosition() end local function snap(x) return math.round(x/GRID_SIZE)*GRID_SIZE end -- Calculates the models position based on grid local function calculateItemPosition() if moveByGrid then posX = snap(mouse.Hit.X) posY = mouse.Hit.Y posZ = snap(mouse.Hit.Z) else posX = mouse.Hit.X posY = mouse.Hit.Y posZ = mouse.Hit.Z end end -- Sets models position based on pivot local function translateObj() if placedObjects and object.Parent == placedObjects then calculateItemPosition() object:PivotTo(CFrame.new(posX, posY, posZ)) end end local function approvePlacement() return true end -- Constructor function function placement.new (g, objs, r, t) local data = {} local metaData = setmetatable(data, placement) GRID_SIZE = g ITEM_LOCATION = objs ROTATE_KEY = r TERMINATE_KEY = t data.grid = GRID_SIZE data.itemlocation = ITEM_LOCATION data.rotatekey = ROTATE_KEY data.terminatekey = TERMINATE_KEY return data end -- activates placement (id = name,pobjs = placedObjects, plt = plot, stk = stackable) function placement:activate(id, pobjs, plt, stk) -- Assigns values for necessary object = ITEM_LOCATION:FindFirstChild(id):Clone() placedObjects = pobjs plot = plt stackable = stk -- Make sure placement can activate properly if not approvePlacement() then return "Placement could not activate" end -- Filters objeccts from mouse depending on stackable variable if not stackable then mouse.TargetFilter = placedObjects else mouse.TargetFilter = object end object.Parent = placedObjects end runService:BindToRenderStep("Input", Enum.RenderPriority.Input.Value, translateObj) return placement