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