I am making a sandbox game, and when i press a button, it should make the item that a player is placing higher or lower. This is the Client Placing Script:
local player = script.Parent.Parent.Parent
local placementHandler = require(script:WaitForChild("PlacementModule"))
if player.team == game.Teams.Lavender then
base = workspace.Lavender
elseif player.team == game.Teams.Mint then
base = workspace.Mint
elseif player.team == game.Teams.Toothpaste then
base = workspace.Toothpaste
elseif player.team == game.Teams.White then
base = workspace.White
end
local items = game:GetService("ReplicatedStorage").Items
local plane = placementHandler.new(base.Baseplate, base.ItemHolder, 1)
local dummyModel
local signal
local currentItemName
local function cancelPlacement()
if (currentItemName) 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
--
local function onKeyPress4(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Up then
dummyModel.MainPart.Position = Vector3.new(dummyModel.MainPart.Position.X,dummyModel.MainPart.Position.Y + 1,dummyModel.MainPart.Position.Z)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress4)
local function onKeyPress5(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Down then
dummyModel.MainPart.Position = Vector3.new(dummyModel.MainPart.Position.X,dummyModel.MainPart.Position.Y - 1,dummyModel.MainPart.Position.Z)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress5)
--
dummyModel.Parent = workspace
local signal = plane:enable(dummyModel)
signal:connect(function(location, _)
game:GetService("ReplicatedStorage").ClientPlaced:FireServer(currentItemName, location)
end)
end
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.P then
initiatePlacement("Platform")
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
function onKeyPress2(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.L then
initiatePlacement("Lava")
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress2)
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
function onKeyPress3(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Q then
cancelPlacement()
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress3)
player.Character:WaitForChild("Humanoid").Died:connect(function()
cancelPlacement()
end)
This is the server placement script:
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()
if player.team == game.Teams.Lavender then
item.Parent = workspace.Lavender.ItemHolder
elseif player.team == game.Teams.Mint then
item.Parent = workspace.Mint.ItemHolder
elseif player.team == game.Teams.Toothpaste then
item.Parent = workspace.Toothpaste.ItemHolder
elseif player.team == game.Teams.White then
item.Parent = workspace.White.ItemHolder
end
item:SetPrimaryPartCFrame(location.X,location.Y,location.Z)
end
end)
This is the part of the scripts that I'm worried about:
Client:
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
--
local function onKeyPress4(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Up then
dummyModel.MainPart.Position = Vector3.new(dummyModel.MainPart.Position.X,dummyModel.MainPart.Position.Y + 1,dummyModel.MainPart.Position.Z)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress4)
local function onKeyPress5(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Down then
dummyModel.MainPart.Position = Vector3.new(dummyModel.MainPart.Position.X,dummyModel.MainPart.Position.Y - 1,dummyModel.MainPart.Position.Z)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress5)
--
dummyModel.Parent = workspace
local signal = plane:enable(dummyModel)
signal:connect(function(location, _)
game:GetService("ReplicatedStorage").ClientPlaced:FireServer(currentItemName, location)
end)
end
Server:
item:SetPrimaryPartCFrame(location.X,location.Y,location.Z)
When i press the button, it works to make the dummy model go up, but when I try to place the item, it gives the error message:
15:51:58.268 - Argument 1 missing or nil
15:51:58.268 - Stack Begin
15:51:58.269 - Script 'ServerScriptService.ServerPlacement', Line 17
15:51:58.269 - Stack End
Please help me, I need to know how to fix this.

3 comments
now, the object doesn't place.
at least there's no error messages
also i already tried that