Error with PlacementService [Re]

I’m using PlacementService with a tutorial, but at 9:00 when the button is pressed, I get an error instead of the expected output.

Error here:

  ReplicatedStorage.Modules.PlacementService:899: attempt to index nil with 'Clone' - PlacementService:899
  Stack Begin
  Script 'ReplicatedStorage.Modules.PlacementService', Line 899 - function activate - PlacementService:899
  Script 'Players.PizzaArmy333.PlayerGui.BuildUI.clientPlacement', Line 21 - function place - clientPlacement:21
  Script 'Players.PizzaArmy333.PlayerGui.BuildUI.clientPlacement', Line 25 - clientPlacement:25
  Stack End

Line 899:

object = self.Prefabs:FindFirstChild(tostring(ID)):Clone()

i can provide more info if needed

2 Likes

What is your code? It’s most likely not a problem with a module, but a problem with your own code.

1 Like
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")

local modules = replicatedStorage:WaitForChild("Modules")
local models = replicatedStorage:WaitForChild("Models")
local placementModule = require(modules:WaitForChild("PlacementService"))

local placement = placementModule.new(
	2,
	models,
	Enum.KeyCode.R, Enum.KeyCode.X, Enum.KeyCode.U, Enum.KeyCode.J
)

local button = script.Parent.Place

local plot = workspace.Plots.Plot1
local plotOBJ = plot.Plot
local itemHolder = plot.itemHolder

local function place(obj, stack, rot)
	placement:activate(obj, itemHolder, plotOBJ, stack, rot)
end

button.MouseButton1Click:Connect(function()
	place("part", true, false)
end)
1 Like

Do you have an object named part in the prefabs?

1 Like

No, I kinda just went in blindly, but i dont see anything named Prefabs parented to the module

1 Like

In the video you showed, he added this:
image

1 Like

I do have a model with all the requirements

snipfast1

1 Like

Sorry, I’ve never used PlacementService before, but did the Models folder come with a capitalized name?

1 Like

The tutorial creator said he was using lowercase to type easier, and the folders were manually added it didnt come with the module

1 Like

It’s because you’re trying to reference a model named “part” when you have a model named “Part”.

Code:

local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")

local modules = replicatedStorage:WaitForChild("Modules")
local models = replicatedStorage:WaitForChild("Models")
local placementModule = require(modules:WaitForChild("PlacementService"))

local placement = placementModule.new(
	2,
	models,
	Enum.KeyCode.R, Enum.KeyCode.X, Enum.KeyCode.U, Enum.KeyCode.J
)

local button = script.Parent.Place

local plot = workspace.Plots.Plot1
local plotOBJ = plot.Plot
local itemHolder = plot.itemHolder

local function place(obj, stack, rot)
	placement:activate(obj, itemHolder, plotOBJ, stack, rot)
end

button.MouseButton1Click:Connect(function()
	place("Part", true, false)
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.