-- variables --
local myHuman = script.Parent:WaitForChild("Humanoid")
local myRoot = script.Parent:WaitForChild("HumanoidRootPart")
local spawn = game.Workspace.SpawnLocation
-- services --
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath()
-- etc --
function Detect(target)
print("Running Detect at", tick())
for _,v in ipairs(workspace:GetChildren()) do
local human = v:FindFirstChild("Humanoid")
local humanoidRootPart = v:FindFirstChild("HumanoidRootPart")
target = humanoidRootPart
end
if target then
path:ComputeAsync(myRoot.Position, target.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
if waypoint then
local part = Instance.new("Part")
part.Shape = "Ball"
part.Position = waypoint.Position + Vector3.new(0,3.5,0)
part.Parent = game.Workspace
part.CanCollide = false
part.Color = Color3.new(1, 0, 0.0156863)
part.Anchored = true
part.Transparency = 0.5
print("Found")
myHuman:MoveTo(waypoint.Position)
myHuman.MoveToFinished:Wait()
end
print(target,",","And Also:", target.Parent.Name)
end
end
end
end
while true do
task.wait(1)
Detect()
end```
#My script is running once can anyone help im kinda new
1 messages · Page 1 of 1 (latest)
-- variables --
local myHuman = script.Parent:WaitForChild("Humanoid")
local myRoot = script.Parent:WaitForChild("HumanoidRootPart")
local spawn = game.Workspace.SpawnLocation
-- services --
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath()
-- etc --
function Detect(target)
print("Running Detect at", tick())
for _,v in ipairs(workspace:GetChildren()) do
local human = v:FindFirstChild("Humanoid")
local humanoidRootPart = v:FindFirstChild("HumanoidRootPart")
target = humanoidRootPart
end
if target then
path:ComputeAsync(myRoot.Position, target.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
if waypoint then
local part = Instance.new("Part")
part.Shape = "Ball"
part.Position = waypoint.Position + Vector3.new(0,3.5,0)
part.Parent = game.Workspace
part.CanCollide = false
part.Color = Color3.new(1, 0, 0.0156863)
part.Anchored = true
part.Transparency = 0.5
print("Found")
myHuman:MoveTo(waypoint.Position)
myHuman.MoveToFinished:Wait()
end
print(target,",","And Also:", target.Parent.Name)
end
end
elseif not target then
warn("No Target Found~")
end
end
while true do
print("Running")
task.wait(1)
Detect()
print("Repeating")
end
It is still running, your "target" condition just isn't validating.
Is this ChatGPT
100000000%%%%
alr thanks for debugging it
no prob