local g=game.ReplicatedStorage.Sounds.NPC.Gobbler:GetChildren()critter.Health.Changed:connect(function()local V=g[math.random(1,#g)]:Clone()V.Parent=critter.PrimaryPart V.PlayOnRemove=true wait()V:Destroy()end)while true do bp.Parent=critter.PrimaryPart local g repeat local V=Ray.new(Vector3.new(origin.p.x+math.random(-tether,tether),critter.PrimaryPart.Position.Y+100,origin.p.z+math.random(-tether,tether)),Vector3.new(0,-130,0))local S,I,J,R=workspace:FindPartOnRay(V,critter)if S==workspace.Terrain and R~=Enum.Material.Water then g=I+Vector3.new(0,2.25,0)end wait()until g walk:Play()local V=critter.PrimaryPart.Position local S=CFrame.new(Vector3.new(V.X,0,V.Z),Vector3.new(g.X,0,g.Z))bg.CFrame=S bp.Position=(S*CFrame.new(0,0,-100)).p local I=tick()repeat wait(.5)local V=Ray.new(critter.PrimaryPart.Position,Vector3.new(0,-140,0))until(critter.PrimaryPart.Position-g).magnitude<10 or tick()-I>10 walk:Stop()bp.Parent=nil wait(math.random(3,8))end

local soundBank =  game.ReplicatedStorage.Sounds.NPC.Gobbler:GetChildren()
critter.Health.Changed:connect(function()
    local hitSound = soundBank[math.random(1,#soundBank)]:Clone()
    hitSound.Parent = critter.PrimaryPart
    hitSound.PlayOnRemove = true
    wait()
    hitSound:Destroy()
end)

while true do
    bp.Parent = critter.PrimaryPart
    local goal
    repeat 
    local ray = Ray.new(Vector3.new(origin.p.x+math.random(-tether,tether), critter.PrimaryPart.Position.Y+100, origin.p.z+math.random(-tether,tether)),Vector3.new(0,-130,0))
    local part,pos,norm,mat = workspace:FindPartOnRay(ray,critter)
    if part == workspace.Terrain and mat ~= Enum.Material.Water then
        goal = pos+Vector3.new(0,2.25,0)
    end
    wait()
    until goal
    --Set new goal for critter to MoveTo :)
    walk:Play()
    local pos = critter.PrimaryPart.Position
    local cf = CFrame.new(Vector3.new(pos.X, 0, pos.Z), Vector3.new(goal.X, 0, goal.Z))
    bg.CFrame = cf
    bp.Position = (cf*CFrame.new(0,0,-100)).p
    
    local start = tick()
    repeat wait(.5)
    local ray = Ray.new(critter.PrimaryPart.Position, Vector3.new(0,-140,0))
    
    until (critter.PrimaryPart.Position-goal).magnitude < 10 or tick()-start >10
    walk:Stop()
    bp.Parent = nil
    wait(math.random(3,8))
end
