Hello developers I need help with a script of a Sandbox Placement

The script has a problem I tried to solve but it does not work here I show you an image that Sandbox Placement I did with a tutorial but I already saw the tutorial 5 times but it does not work for me it is still the same if someone can please check the code for me would be very grateful

that’s the local script that goes in gui --StarterGui –

local placementHandler = require(script:WaitForChild(“PlacementModule”))
local base = workspace.Base
local items = game:GetService(“ReplicatedStorage”).Items
local plane = placementHandler.new(base.Baseplate, base.ItemHolder, 3)

local texBox = script.Parent:WaitForChild(“TextBox”)

local dummyModel
local signal
local currentItemName

local function cancelPlacement()
if (dummyModel) then
plane:disable()
if (dummyModel.Parent) then
dummyModel:Destroy()
end

	dummyModel = nil
	signal = nil
	currentItemName = nil
end

end

local function initiatePlacement(itemName)
cancelPlacement()

dummyModel = items[itemName]:clone()

currentItemName = itemName

for _, object in pairs(dummyModel:GetChildren()) do
	if (object:IsA("BasePart")) then
		object.CanCollide = false
	end
end

dummyModel.Parent = workspace

local signal = plane:enable(dummyModel)

signal:connect(function(location, _)
	game:GetService("ReplicatedStorage").ClientPlaced:FireServer(currentItemName, location)

	cancelPlacement()
end)

end

texBox.FocusLost:connect(function(enterPressed)
if (enterPressed) then
local text = texBox.Text
if (items:FindFirstChild(text)) then
initiatePlacement(text)
end
end
end)

and that’s a normal script – ServerScriptService –

local items = game:GetService(“ReplicatedStorage”).Items

game:GetService(“ReplicatedStorage”).ClientPlaced.OnServerEvent:Connect(function(player, itemName, location)
local itemTemplate = items:FindFirstChild(itemName)

if (itemTemplate) then
	local item = itemTemplate:clone()
	item.Parent = workspace.Base.ItemHolder
	item:SetPrimaryPartCFrame(location)
end

end)

Please reformat your script, and change the category to #help-and-feedback:scripting-support, thanks!

1 Like

Try putting warns or prints in between to check where the error is. Also, use the output to directly access where the code didn’t work.

1 Like

See developers I put the code and video because according to me it’s fine I’ve already reviewed it about 5 times and it doesn’t work for me that’s why I put the code and video because maybe I put the script wrong :thinking: :face_with_raised_eyebrow:

Could you put your code in a full codeblock so we can read it better and help? Also just to clarify, are there any errors? If so, could you say what line and, if needed, which line is which?

You put codeblocks in by typing ``` then putting your code in the middle then typing another set of ```.

Well in the model I came no script I only came a part where there are going to be linked to the model that calls it PrimaryPart there is a section where it says of the example model is where the players will use to see where they will place the said object and for the script the error does not appear is that line item: SetPrimaryPartCFrame (location)

example:


It makes sense that you are doing an npc but it is not npc what you are going to do is the following you are going to vicular the model a part you can call it PrimaryPart

that’s an example :point_left: :grinning:

Ah, I know why it gives an error on the platform, it is the page that puts it like that, true "

replace in those signs "as they are in the image with all

and after solving that problems Placement Handler (V2) - Roblox :point_left: in the video