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

Move model PrimaryPart y position only?

What am I doing wrong here? The commented line is what I was trying to do as it would move the whole model. However, I get an error that says "Unable to cast double to CoordinateFrame"

What this is supposed to do is if the y position is greater then 20 then it will bring the model down to a y of 10

local PrimaryPart = script.Parent.PrimaryPart
local Model = script.Parent

while true do
	wait()
	if PrimaryPart.Position.Y > 20 then
		PrimaryPart.Position = Vector3.new(PrimaryPart.Position.X, 10, PrimaryPart.Position.Z) -- Doesn't move the whole model
		--Model:SetPrimaryPartCFrame(PrimaryPart.Position.X, 10, PrimaryPart.Position.Z)
	end
end

1 answer

✓ Accepted answer

You did everything right, you just forgot a few things. If you want to use a Vector3 to move the entire model, use:

model:MoveTo(Vector3.new(0,0,0))

If you want to position the model using a CFrame, you did it right except you're trying to make the CFrame out of 3 numbers, when you should be making it out of a Vector3. Just change it so there's a Vector3.new() around the 3 numbers inside the CFrame.new for your model:SetPrimaryPartCFrame

3 comments

0

Well the problem with doing model:SetPrimaryPartCFrame(Vector3.new(0,0,0) ) is you will get a error of "Unable to cast Vector3 to CoordinateFrame"

0

Oops, I see what you mean. Thanks man! I didn't think of using the MoveTo function.

0

Also, that's why I said you put the Vector3.new() INSIDE the CFrame.new().

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