Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The Humanoid Wont Move?

So I'm trying to make a character that scans for the closest marker and then moves to it but I don't know why it isn't working.

game:WaitForChild("Workspace")

local markers = game.Workspace.Markers:GetChildren()
local hum = script.Parent.Humanoid
local humRoot = script.Parent.HumanoidRootPart


local function findClosestMarker()
	local currentMarker = nil
	local shortestMarker = math.huge
	local chosenMarker = nil
	
	for i, marker in pairs(markers) do
		local distance = (marker.Position - humRoot.Position).magnitude
		currentMarker = distance
		if currentMarker <= shortestMarker then
			shortestMarker = currentMarker
			chosenMarker = marker
			print("Found Closer Marker")
			
		elseif currentMarker > shortestMarker then
			print("Did Not Find Closer Marker")
		end
	end
	return chosenMarker
end

hum:MoveTo(findClosestMarker().Position)
hum.MoveToFinished:Wait()

1 answer

So it turns out I'm actually just stupid and spent 10 hours total trying to figure this out. part of the character was anchored

This discussion is preserved as it was. New answers, comments, and votes are closed.