i'm uh,, confused on how models have no position property,, and i dont know how to make a model move as a whole. like,
i'm trying to make this model move until it stops on a specific position. how do i do that if a model has no position property? is there a function for it?
To simply move a model, you can use the :SetPrimaryPartCFrame()
method like so:
local model = workspace.Model model:SetPrimaryPartCFrame(CFrame.new(0,0,0))
If you have a model with a humanoid in it (such as an NPC), you can use the :MoveTo()
method. Please note that this method exists in models and humanoids, but when called upon a humanoid, it will cause the character to walk to the given point.
local npc = workspace.NPC npc.Humanoid:MoveTo(Vector3.new(0,0,0))
Additionally, this method can be paired with the MoveToFinished
event to detect when the character has reached their destination.
local npc = workspace.NPC npc.Humanoid:MoveTo(Vector3.new(0,0,0)) npc.Humanoid.MoveToFinished:Connect(function(reached) print("Destination Reached!") end)
The reached
parameter returns true if the goal is reached within 8 seconds. Otherwise, it returns false.