If this is still maintained, I recommend using attachments to attach parts together. Would be useful for more sandbox-oriented environments.
@3QAXM This will come out in an update once I figure out how to add this. I’ve tried many times but never have been able to get it to work. But yes, I do want to add this as it’s the #1 request I get.
@CreepdaSheep Please DM me with more details about this issue.
@corehimself Please DM me with more information on your suggestion.
I started using this and it’s absolutely amazing. Added my own mobile UI and now trying to figure out how to make wall placing possible… You had any luck so far? @zblox164
Mobile UI isn’t handled internally by the module to make it as customizable as possible. To get mobile UI working, you have to use the functions to place, rotate, cancel, and change floors when you click each button. You can see more through these links to the API:
https://zblox164.github.io/PlacementService/API/#placementinforaise
https://zblox164.github.io/PlacementService/API/#placementinfolower
https://zblox164.github.io/PlacementService/API/#placementinforotate
https://zblox164.github.io/PlacementService/API/#placementinfoterminate
https://zblox164.github.io/PlacementService/API/#placementinforequestplacement
https://zblox164.github.io/PlacementService/API/#placementinfogetplatform
Hey there, i just set up this module and i keep getting this error:
ReplicatedStorage.Modules.PlacementService:899: attempt to index nil with 'FindFirstChild'
Do you know how to fix this?
@EverDaleTop @PizzaArmy333 Please do not ask for assistance with the module usage and potential bugs or issues here. Instead, please tag me in a #help-and-feedback:scripting-support post or DM me directly and I’ll respond when I get the chance.
What would be the best way to configure the system to allow for a player deleting already placed objects
I came back to an old project of mine which had the bones of a placement system in it this week, and I’ve been absolutely banging my head against a wall for days making incremental progress (partly because the original implementation was awful and I was building on it, but partly just because it’s a pretty big undertaking trying to get it right). I finally gave in after everything had become spaghetti code and I was on the brink of binning it all and starting over, and found this.
This has got to be one of the best documented Roblox libraries I’ve ever seen - the attention to detail in both the API and the support you’ve been giving on here is incredible, and I wanted to say how much I appreciate what you’ve been giving to the community here. I’m going to give this a shot tomorrow, but I expect that this will be everything I need, and if it’s not this will be a perfect base to build off to get what I’m looking for, thanks.
I’m really glad you and many others have found this useful. Especially since it has taken many hours to develop. I also am happy to hear you found the documentation useful. Hearing developers like yourself mention things like this definitely helps keep me motivated to continue the development of the module and support it for years to come!
If you have any questions about the usage of the module, feel free to reach out. I’ll respond as soon as I can!
Thanks for using the module, hopefully it fulfills your needs!
I have a problem with this:
local function verifyPlane()
return plot.Size.X%GridSize == 0 and plot.Size.Z%GridSize == 0
end
I recently just saw your tutorial number 3 and when I went to test it, I got the following error:
09:58:51.184 Script 'ReplicatedStorage.modules.placementHandler', Line 79 - function verifyPlane - Studio - placementHandler:79
09:58:51.184 Script 'ReplicatedStorage.modules.placementHandler', Line 84 - function approvePlacement - Studio - placementHandler:84
09:58:51.184 Script 'ReplicatedStorage.modules.placementHandler', Line 125 - function activate - Studio - placementHandler:125
Now none of the code works, please help me.
Here I leave you the complete code:
-- Settings
-- Bools
local interpolation = true
local moveByGrid = true
local buildModelPlacement = true
-- Ints
local rotationStep = 90
local maxHeight = 90
-- Floats
local lerpLevel = 0.3 -- 0 = instant snapping, 1 = no movement at all
-- 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 GridSize : number
local ItemLocation
local RotateKey
local TerminateKey
-- Action Variables
local object
local placedObjects
local plot : BasePart
local stackable
-- Variables used in calculations
local posX
local posY
local posZ
local speed = 1
-- Calculates the initial y position
local function calculateYPosition()
end
local function snap(x)
return math.round((x/GridSize) + 0.5)*GridSize
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(object.PrimaryPart.CFrame:Lerp(CFrame.new(posX, posY, posZ), speed))
end
end
-- Check if the model will snap evenly on the plot
local function verifyPlane()
return plot.Size.X%GridSize == 0 and plot.Size.Z%GridSize == 0
end
-- Confirms that the settings are valid for placement
local function approvePlacement()
if not verifyPlane() then
warn("The model cannot snap on the plot. Please change the plot size to fix this")
return false
end
if GridSize > math.min(plot.Size.X, plot.Size.Z) then
warn("Grid size is too big for this plot")
return false
end
return true
end
-- Constructor function
function placement.new(g, objs, r, t)
local data = {}
local metaData = setmetatable(data, placement)
GridSize = g
ItemLocation = objs
RotateKey = r
TerminateKey = t
data.grid = GridSize
data.itemLocation = ItemLocation
data.rotateKey = RotateKey
data.terminatekey = TerminateKey
return data
end
-- Activates placement(id = name, pobjs = placedObjects, plt = plot, stk = stackable)
function placement:activate(id, pobjs, plt, stk)
-- Assigns values for necessary variables
object = ItemLocation:FindFirstChild(id):Clone()
placedObjects = pobjs
plot = plt
stackable = stk
if not approvePlacement() then
return "Placement couldn0t"
end
-- Filter objects from mouse depending on stackable variable
if not stackable then
mouse.TargetFilter = placedObjects
else
mouse.TargetFilter = object
end
-- Sets up interpolations speed
local preSpeed = 1
if interpolation then
preSpeed = math.clamp(math.abs(tonumber(1 - lerpLevel)), 0, 0.9)
speed = 1
end
object.Parent = placedObjects
wait()
speed = preSpeed
end
runService:BindToRenderStep("Input", Enum.RenderPriority.Input.Value, translateObj)
return placement
This post is relating to my module Placement Service. This is not the thread to ask questions from my tutorial series.
So I have set this up in my studio, by I keep getting an error.
ReplicatedStorage.modules.PlacementService:899: attempt to index nil with ‘Clone’
Make sure the object within models have a primarypart set
This module works perfectly! Except I have one issue, when I click my “Enable Build Mode” button well in build mode (which usually would just deactivate build mode) it gives me the error
ContextActionService: Unexpected error while invoking callback: ReplicatedStorage.Modules.PlacementService:541: attempt to index nil with 'Destroy'
Here’s my script for the “Enable Build Mode” button:
-- Services
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
-- Variables
local player = players.LocalPlayer
local mouse = player:GetMouse()
local modules = replicatedStorage:WaitForChild("Modules")
local placementService = require(modules.PlacementService)
local models = replicatedStorage:WaitForChild("Models")
local signals = replicatedStorage:WaitForChild("Signals")
local remotes = signals.Remotes
local remoteFunctions = remotes.Functions
local remoteEvents = remotes.Events
local requestPlacement = remoteFunctions.RequestPlacement
local getPlot = remoteFunctions.GetPlot
local placement = placementService.new(
1,
models,
Enum.KeyCode.R,
Enum.KeyCode.C,
Enum.KeyCode.E,
Enum.KeyCode.Q
)
local button = script.Parent.Place
local plot = getPlot:InvokeServer()
local plotObject = plot.Plot
local itemHolder = plot.ItemHolder
-- Functions
local function place(objectName, stackable, smartRotation)
placement:activate(objectName, itemHolder, plotObject, stackable, smartRotation)
end
button.MouseButton1Click:Connect(function()
place("Conveyor", false, false)
end)
mouse.Button1Down:Connect(function()
placement:requestPlacement(requestPlacement)
end)
Hey!
How different will the API be for Placement Service v4?
Will it have the same API or will it be slightly different?
The API will be slightly different but I am planning on also always offering a legacy version. It just wont get any updates. The base of the functionality will definitely stay similar though.
Not sure if this question was already answered before, but can you delete tiles?