Hello, I have a model, but I need to make the model without using :SetPrimaryPartCFrame, and :GetPrimaryPartCFrame. Also, my model has sensors using “Touched” event, but someone told me that using CFrames will not trigger the Touched event. How can I make this? Thank you.
local model = --model path here
local function moveModel()
local pos = --position path here. has to be a vector3 value.
model:MoveTo(pos)
end
moveModel() --initiates the function and moves the model.
Thanks, but I want the car to move forever, not having a certain position to stop.
Please specify that the model is a car. I recommend you use bodymovers or hinge constraints with the motor
actuator type. it gives you a result like this when the wheels spin, and you can mess around with maxforce.
Also, does the “pos” mean that I have to put a certain position?
dont worry about that script now, it’s not correct because you want a car to move. is it a controlled car or does it automatically drive?
It is an automatically driven car.
have you looked into pathfinding? i dont know if thats for models without humanoids or not, but it’s worth a research
you could use CFrame:Lerp if your just planning to make a part go to one position
i used Lerp to move NPC around but as you know it didnt work well and i suggest that you dont use Lerp if you have multiple points that the model has to move to
im assuming your trying to use a touch event to try and stop the model from moving
i tried that once and the result was if your moving is using positing to move it wont detect it at all
maybe magnitude would work but i failed trying that one cuz im not experienced with handling magnitude
I don’t want to use path finding, because I want to do with scripts.
you could use Humanoid:MoveTo() function to move your model around if it has a humanoid and model is not anchored
Yes, I just want to change the script so that the Touched events could work.
if you just want your touch event to work you have to think of a way for the parts to bump into each other while physics is applied
I have this script from a YouTube tutorial, and this seems to be the problem that prevents from the Touched event from working.
This is the script:
local drivingCar = script.Parent
wait(5)
while wait(0.00000001) do
drivingCar:SetPrimaryPartCFrame(drivingCar:GetPrimaryPartCFrame() * CFrame.new(0, 0, -0.5))
end
can you send me the link to the YT tutorial
You can just search up “How to move a model in Roblox Studio”, and a video from a YouTuber called “Previized” from 4 years ago.
My recommendation would be to weld all the car parts to a part that you want to be the root part of the model. Anchor the root part, and then unanchor everything else.
At that point, you have a lot of options as to what you can do. You could use BodyMovers (like BodyPosition) in that root part to move it where you want to go, and all of the other parts will follow. Or, you could use TweenService to create a smooth movement effect to a desired end point.
to honest if your looking to make a car i would just use roblox constraints like hinges
these are tutorials
they are 7 years ago so im not sure if their out dated or not
but their looking similar to how it works now so im sure enough
im pretty sure you could make the car move on its own with some messing around with hinges if a player driving car is not what you want
Thanks, but I wouldn’t use Hinges, or Vehicle seats as I don’t want the car driven by the player.