SetPrimaryPartCFrame Help

I have a script that uses SetPrimaryPartCFrame and I’m not sure what to put in the second part of it. I’m trying to change a models’ position and this is the part of my script that does it.

clone:SetPrimaryPartCFrame(CFrame.new(tool.Parent.HumanoidRootPart.Position, --This is the part I don't know what to put))
1 Like

You could put the tool.Parent.HumanoidRootPart’s orientation if your trying to rotate it.

I tried doing

clone:SetPrimaryPartCFrame(CFrame.new(tool.Parent.HumanoidRootPart.Position, tool.Parent.HumanoidRootPart.Orientation))

but it still doesn’t work.

I’m pretty sure SetPrimaryPartCFrame requires 1 argument and your feeding it 2 seperate CFrame values right?

Try to plus both of the CFrame values.

1 Like

What do you mean? I’m a bit confused.

Try to plus both of the CFrame values and see what you get, In which I mean:

local CFrameValue = tool.Parent.HumanoidRootPart.Position + tool.Parent.HumanoidRootPart.Orientation

Neither of those worked. :pensive:

You don’t need to put anything in the second argument, the latter is replaced with CFrame.lookAt.
If all you are doing is setting the clone’s position to that tool’s location, then you just do:

clone:SetPrimaryPartCFrame(CFrame.new(tool.Parent.HumanoidRootPart.Position))
1 Like

I’ve tried that before but it doesn’t work.

Try it now and tell me what’s the error, it doesn’t make sense for it to just not work.

If your trying to change a model’s CFrame to the tool then maybe try this?

clone:SetPrimaryPartCFrame(tool.Parent.HumanoidRootPart.CFrame)
1 Like

It doesn’t print any errors…

That didn’t work either. :neutral_face:

Make sure that you have a PrimaryPart and check if it has moved or not.

You only need one part to the functoin.

There is no way it doesn’t work because what he said was wrong, something you are doing is wrong.

Does your clone have a primary part?

Ok, guys, this is what my entire script looks like:

local tool = script.Parent
local remote = tool:FindFirstChild("RemoteEvent") or tool:WaitForChild("RemoteEvent")
local clone

remote.OnServerEvent:Connect(function(_, toggle)
	if clone then
		clone:Destroy()
		clone = nil
	end

	if not toggle then return end

	clone = game:GetService("ServerStorage").Trolly:Clone()
	clone.Parent = tool.Parent
	clone.Primary.WeldConstraint.Part1 = tool.Parent.HumanoidRootPart
	clone:SetPrimaryPartCFrame(CFrame.new(tool.Parent.HumanoidRootPart.Position, --This is the part I don't know what to put))
end)

I also have a local script that fires the event:

local tool = script.Parent
local remote = tool:FindFirstChild("RemoteEvent") or tool:WaitForChild("RemoteEvent")

tool.Equipped:Connect(function()
	remote:FireServer(true)
end)

tool.Unequipped:Connect(function()
	remote:FireServer(false)
end)

And this is what my explorer looks like:

Does your Trolly have a PrimaryPart or not

1 Like

See what fires and what doesn’t using print debugging. If it actually gets to the line of the code where it sets the CFrame of the PrimaryPart, then you most likely don’t have a PrimaryPart assigned.

1 Like