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
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)
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)