Error with making placement system server sided

Little confused here on why it thinks it is a player…

Error: " Parent of Player can not be changed" (Coming from the server)

Localscript:

script.Parent.Activated:Connect(function()
			if Equipped then
				if PartPreview.PrimaryPart then
						local PartPlacement = game.ReplicatedStorage.Models:WaitForChild(Settings.PartModel):Clone()
					--PartPlacement.Parent = workspace
					local PartPreviewCFrame = PartPreview.PrimaryPart.CFrame
					
					PlaceRemote:FireServer(PartPlacement, PartPreviewCFrame)
					--PartPlacement:SetPrimaryPartCFrame(PartPreview.PrimaryPart.CFrame)
				end
			end
		end)


-- Server Script Service


ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlaceRemote = ReplicatedStorage.Models.PlaceRemote

PlaceRemote.OnServerEvent:Connect(function(PartPlacement, PartPreviewCFrame)
	PartPlacement.Parent = workspace
	PartPlacement:SetPrimaryPartCFrame(PartPreviewCFrame)
end)

The first parameter of the event is player.

The first parameter on a server event is the player, always.
change PlaceRemote.OnServerEvent:Connect(function(PartPlacement, PartPreviewCFrame) to PlaceRemote.OnServerEvent:Connect(function(Player, PartPlacement, PartPreviewCFrame)

“ServerScriptService.Script:7: attempt to index nil with ‘Parent’”

Can you show us the whole script?

Or at least part where you define the values for PartPlacement and PartPreviewCFrame

Players = game:GetService("Players")
ReplicatedStorage = game:GetService("ReplicatedStorage")

local module = ReplicatedStorage:FindFirstChild("PlacementSettings")
local Settings = require(module)
local player = Players.LocalPlayer
local character = workspace:FindFirstChild(player.Name)
local mouse = player:GetMouse()
local Equipped = false
local isRotating = false
local PlaceRemote = ReplicatedStorage.Models.PlaceRemote


script.Parent.Equipped:Connect(function()
	if not Equipped then
		Equipped = true
		local PartPreview = game.ReplicatedStorage.ModelPreview:WaitForChild(Settings.ModelPreview):Clone()
		PartPreview.Parent = workspace
		mouse.TargetFilter = PartPreview
		mouse.Move:Connect(function()
			local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
			PartPreview:MoveTo(Vector3.new(posX,posY,posZ))
		end)

		script.Parent.Activated:Connect(function()
			if Equipped then
				if PartPreview.PrimaryPart then
						local PartPlacement = game.ReplicatedStorage.Models:WaitForChild(Settings.PartModel):Clone()
					--PartPlacement.Parent = workspace
					local PartPreviewCFrame = PartPreview.PrimaryPart.CFrame
					
					PlaceRemote:FireServer(PartPlacement, PartPreviewCFrame)
					--PartPlacement:SetPrimaryPartCFrame(PartPreview.PrimaryPart.CFrame)
				end
			end
		end)

		local uis = game:GetService("UserInputService")

		uis.InputBegan:Connect(function(inputObject, gameProcessEvent)
			if inputObject.KeyCode == Enum.KeyCode.R then 
				if not isRotating and Equipped then
					print("Holding R")
					isRotating = true
					while isRotating do
						PartPreview:SetPrimaryPartCFrame(PartPreview.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(5), 0))
						wait(0.1)
					end
				end
			end
		end)

		uis.InputEnded:Connect(function(inputObject, gameProcessEvent)
			if inputObject.KeyCode == Enum.KeyCode.R then 
				if isRotating then
					print("Stop")
					isRotating = false
				end
			end
		end)

		script.Parent.Unequipped:Connect(function()
			if Equipped then
				Equipped = false
				PartPreview:Destroy()

			end
		end)
	end
end)
1 Like

Seems great for me. Although I may be wrong, because I’m on mobile.

It only shows on client, I want to show on server too

Things in local scripts are shown only for the clients so you have that script to show it on server in the server script, right?

Yes, that is correct that I what I am attempting to do

Then, I have no idea why it won’t show up on the server.

This is my error:
““ServerScriptService.Script:7: attempt to index nil with ‘Parent’””

That errored with this when I tried that

This means it’s not getting the PartPlacement variable. You didn’t try to send the player from the client did you? Also, game.ReplicatedStorage.Models:WaitForChild(Settings.PartModel) looks odd. The thing inside WaitForChild has to be a string that is the name of the instance. Is this the case?
Sorry for the late response I’m pretty busy.