#Path finding script with emotions gone wrong
1 messages · Page 1 of 1 (latest)
local PathfindingService = game:GetService("PathfindingService")
local npc = script.Parent
local humanoid = npc:FindFirstChildOfClass("Humanoid")
local hrp = npc:FindFirstChild("HumanoidRootPart")
local fearedFolder = npc:FindFirstChild("Feared")
if not humanoid or not hrp then
warn("NPC missing Humanoid or HumanoidRootPart")
return
end
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid
end
local walkAnim = Instance.new("Animation")
walkAnim.AnimationId = "rbxassetid://180426354"
local walkTrack = animator:LoadAnimation(walkAnim)
local jumpAnim = Instance.new("Animation")
jumpAnim.AnimationId = "rbxassetid://125750702"
local jumpTrack = animator:LoadAnimation(jumpAnim)
humanoid.Running:Connect(function(speed)
if speed > 0.1 then
if not walkTrack.IsPlaying then
walkTrack:Play()
end
else
if walkTrack.IsPlaying then
walkTrack:Stop()
end
end
end)
humanoid.Jumping:Connect(function(active)
if active then
jumpTrack:Play()
else
jumpTrack:Stop()
end
end)
local wanderRadius = 20
local function getRandomOffset(radius)
local x = (math.random() - 0.5) * 2 * radius
local z = (math.random() - 0.5) * 2 * radius
return Vector3.new(x, 0, z)
end
local function isWaypointClear(position)
for _, otherNpc in ipairs(workspace:GetChildren()) do
if otherNpc ~= npc and otherNpc:IsA("Model") then
local otherHrp = otherNpc:FindFirstChild("HumanoidRootPart")
if otherHrp then
if (otherHrp.Position - position).Magnitude < 3 then
return false
end
end
end
end
return true
end
omg bra
doesnt let me send the other part
send as .txt
ok
how can i do that
ah
whats the problem with the script
what does that meean
so theres a part of the script
wich
does an fear emotion kind of
but
it doesnt detect the player
nor run once the player is near the npc
what should it do when it runs
run away from the player
seems to work for me
is ur fearfolder set correctly?
test this
local fearedNames = {"Ur name goes here"}
oh shoot
did u forgeet to make it?