Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I cannot figure out to implement SetPrimaryPartCFrame() into my script, any fixes?

I need to move an entire model, but I can't figure out how to implement SetPrimaryPartCframe(),

I cannot use Model:MoveTo. Because I do not it want to avoid objects. The code is right here,

local main = workspace.Plane:SetPrimaryPartCFrame()

script.Parent.MouseClick:Connect(function()

while true do
	if _G.time == 1 then
			main.Position = main.Position + Vector3.new(0, 0.25, -1)
	wait(0.05)

			else 

		main.Position = main.Position + Vector3.new(0, 0, -0.75)
		main.Orientation = Vector3.new(0,0,0)
		wait(0.05)

		end
	end
end)

I get this error, 00:43:33.502 - Argument 1 missing or nil

1 answer

It is because in the :SetPrimaryPartCFrame(), you must add a position inside the method. What this method does is that it sets the model to move to the position, so what you're will essentially be putting in would be the final destination of your model.

If you want to move a model, you can use a for loop in order to do so. Here is an example below.

local Model = game.Workspace.Model

for i = 1, 100, 0.1 do
	Model:SetPrimaryPartCFrame(CFrame.new(1, 2, i))
	wait()
end

--This will make the model slide to its location, if you want it to directly go to its position, ignore the forloop and just set the CFrame to the final destination.

The model in the script will start at CFrame.new(1,2,1) and will end up in the position of CFrame.new(1, 2, 100). You can set the end location to wherever you want.

If you can include more clarification on what you are trying to do, I might be able to help you a bit more.

This discussion is preserved as it was. New answers, comments, and votes are closed.