I am trying to create a cutscene triggered by the player that automatically makes their character move to a certain spot, but whenever I try to call :MoveTo on the players humanoid nothing happens.
This is the code I used in the script:
Trigger.Touched:Connect(function(Part)
if Part.Parent:FindFirstChildWhichIsA("Humanoid") then
Trigger.CanTouch = false
local Humanoid = Part.Parent.Humanoid
local HumanoidRootPart = Part.Parent.HumanoidRootPart
local Player = Part.Parent
Humanoid:MoveTo(Trigger.Part1.Position)
Humanoid.MoveToFinished:Wait()
task.wait(3)
Humanoid:MoveTo(Trigger.Part2.Position)
Humanoid.MoveToFinished:Wait()
Trigger.CanTouch = true
end
end)
The only thing I have thought of is that :MoveTo is not able to be called on a players humanoid, although I read through the entirety of the Humanoid documentation (might have missed something) and couldn’t find anything confirming that suspicion.
Any help or alternative solutions would be greatly appreciated!
Trigger.Touched:Connect(function(Part)
if Part.Parent:FindFirstChildWhichIsA("Humanoid") then
Trigger.CanTouch = false
local Humanoid = Part.Parent.Humanoid
local HumanoidRootPart = Part.Parent.HumanoidRootPart
local Player = Part.Parent
while task.wait(0.2) do Humanoid:MoveTo(Trigger.Part1.Position)
end
Humanoid.MoveToFinished:Wait()
task.wait(3)
while task.wait(0.2) do
Humanoid:MoveTo(Trigger.Part2.Position)
end
Humanoid.MoveToFinished:Wait()
Trigger.CanTouch = true
end
end)
The second MoveTo does not fire after the first because of the loop the first is wrapped in, causing the player to infinitely be moved back to Part1's position
Trigger.Touched:Connect(function(Part)
if Part.Parent:FindFirstChildWhichIsA("Humanoid") then
Trigger.CanTouch = false
local Humanoid = Part.Parent.Humanoid
local HumanoidRootPart = Part.Parent.HumanoidRootPart
local Player = Part.Parent
while task.wait(0.2) do Humanoid:MoveTo(Trigger.Part1.Position)
Humanoid.MoveToFinished:Wait()
break
end
task.wait(3)
while task.wait(0.2) do
Humanoid:MoveTo(Trigger.Part2.Position)
Humanoid.MoveToFinished:Wait()
break
end
Trigger.CanTouch = true
end
end)
I was just about to try this, after a few other ideas including the usage of break.
Thank you (so much) for the help! I really appreciate the time you have taken to write this out, and help me to come up with a solution. Have a great day or night