Why is my :MoveTo() script not working

I want any model certain models that meet the if requirements to move to a certain position once it touches the “MovePart”

the script doesn’t work, I’m not saying the script is the problem, I’m new to scripting so I don’t even know if I can’t do :MoveTo() like this or I made a mistake:

local MovePart = script.Parent

MovePart.Touched:Connect(function(hit)
if hit.Name == ““TouchMovePart”” then
hit.Parent.Parent.Parent:MoveTo(Vector3.new(1,1,1))
end
end)

I think the problem is somewhere in line 4 but idk what

Basically, there is a part in front of the bonnet of the bonnet of the car called ““TouchMovePart””, if that part is the one that touches the “MovePart”, then its parent which is “Car”, and Cars parent which is “Body”, and bodys parnet which is the car, should move to the certain new Vector3? Right?

You need to use Humanoid:MoveTo().

But I’m not moving a humanoid, I’m moving a car

Are you saying if I move the human in the car, I’ll move the car aswell?

Parameters

Name Type Default Description
### position Vector3 The Position the Model is to be moved to.

Returns

Return Type Summary
### void

Yes that is how it works, state the position in a variable or in the vector3.new(positionhere)

how would I go about moving the human?

I’m pretty sure if a human is currently sitting in the car while the human is moved, the car will go along with it. So, @liamazu1000 should be right in this regard.

Ok, thanks all for the info, but how would I go about moving the certain players that is in the car that is supposed to be moved, I mean, how would I address that specific person, and also, would it be a smooth transition or a teleport transition

I’m not sure, sorry. I haven’t worked with cars much. I assume that checking who is sitting in the seat should work.

The question is, how??? Does anyone know?

Model:MoveTo() works, but is not as good as Model:SetPrimaryPartCFrame(). The difference between Model:MoveTo() and Model:SetPrimaryPartCFrame() is that Model:MoveTo() teleports the model, but not always to the exact position, if there’s a blockage or whatnot within the perimeters of the model, it will be teleported above the blockage, and uses Vector3.

Model:SetPrimaryPartCFrame() requires a model PrimaryPart and knowledge of how to use CFrames, but is effective at teleporting to exact positions.

To answer your question, I’m not sure what’s exactly wrong, because your code seems perfectly fine to me. My suggestion is to check the output logs for any errors made by this script.

2 Likes

Thanks for the info, but do you by any chance know how to reference the humanoid driving the car? And is Humanoid:MoveTo() smooth like tweening? Or is it like teleport like SetPrimaryPartCFrame() and MoveTo()?

I’m literally so confused why the script is not working…And idk how to reference the person driving the car

Move to cant be applied to models. It can only apply to humanoids and they are used to make a character walk.

Humanoid:MoveTo() does not work in your case. It makes the character walk to the given Vector3. Some people are spreading misinformation, as Model | Documentation - Roblox Creator Hub exists. The only person who was correct about Model:MoveTo() existing or not was @ItsMeFelixAccept.

3 Likes

Thank you for clearing up the Humanoid:MoveTo() situation, so I can’t do that, but is there a way to make the script work?

As mentioned before, I’m not sure what’s wrong with the script, if you could give proof via the output window or whatnot.

Does the actual script has 2 double-quotes or was it typed wrong?

I haven’t really worked with cars so I’m not sure how to make a fully functional one, but try this:

local MovePart = script.Parent
local Model = MovePart.Parent.Parent

MovePart.Touched:Connect(function(hit)
    if hit.Name == "TouchMovePart" then
       Model:SetPrimaryPartCFrame(CFrame.new(Model:GetPrimaryPartCFrame().LookVector * 5))
    end
end)
1 Like

Omds thank you, I didnt notice. It teleports the car but it also kicks the driver out, I understand you’re not a car guy so you may not know. If you don’t know, that’s fine! I appreciate your help. :+1:

1 Like

You could possibly use this tutorial by Roblox though:

1 Like