Adding the wait() made the player move for a millisecond, a wait(3).
local function onCharacterAdded(character) didn’t seem to work either, neither did setting it to false or true.
local Destination = Vector3.new(3.5, 0.5, -47.5)
local Humanoid = script.Parent:WaitForChild("Humanoid")
local PlayerControls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
PlayerControls:Disable()
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen()
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
moveTo(Humanoid, Destination, function()
PlayerControls:Enable()
script:Destroy()
end)
dude game.Players.LocalPlayer doesn’t do anything.
You have to get their Character then their Humanoid game.Players.LocalPlayer.Character.Humanoid:Move(Vector3.new(3.5, 0.5, -47.5))
Hope this helps
I think it is moving toward the place the camera is pointing
The following example would cause the LocalPlayer to walk forward, towards where their camera is pointing. game.Players.LocalPlayer:Move(Vector3.new(0, 0, -1), true)