I want the npc to walk around the walls even if it cant collide with them.
local TweenService = game:GetService("TweenService")
local Shrek = workspace:WaitForChild("Shrek")
local HumanoidRootPart = Shrek:WaitForChild("HumanoidRootPart")
local Humanoid = Shrek:WaitForChild("Humanoid")
local Locations = script.Parent
local RandomLocations = Locations:WaitForChild("RandomLocations")
local FoodBowl = Locations:WaitForChild("FoodBowl")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LowHunger = ReplicatedStorage:WaitForChild("RemoteEvents").LowHunger
local Path = PathFindingService:CreatePath()
local RandomLocation = RandomLocations:FindFirstChild(math.random(1,12))
Path:ComputeAsync(HumanoidRootPart.Position, RandomLocation.Position)
local Waypoints = Path:GetWaypoints()
Humanoid:MoveTo(RandomLocation.Position)
local MoveRandomly = true
local Stop = false
local Hunger
Humanoid.MoveToFinished:Connect(function(RandomLocation)
LowHunger.Event:Connect(function(Player)
Hunger = Player:WaitForChild("ShrekStats").Hunger
if FoodBowl.FoodInBowl.Value == true then
MoveRandomly = false
Humanoid:MoveTo(FoodBowl.Position)
end
end)
if MoveRandomly == true and Stop == false then
wait(math.random(1,5))
local NewLocation
do repeat
NewLocation = RandomLocations:FindFirstChild(math.random(1,12))
wait()
until
NewLocation ~= RandomLocation
end
Path:ComputeAsync(HumanoidRootPart.Position, NewLocation.Position)
local Waypoints = Path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid:MoveTo(waypoint.Position)
end
elseif MoveRandomly == false and Stop == false then
Hunger.Value = 100
FoodBowl.FoodInBowl.Value = false
TweenService:Create(FoodBowl.Food, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1}):Play()
MoveRandomly = true
FoodBowl.Food.ParticleEmitter.Enabled = true
wait(1)
Hunger.Value = 100
wait(1)
Hunger.Value = 100
wait(1)
Hunger.Value = 100
FoodBowl.Food.ParticleEmitter.Enabled = false
local NewLocation
do repeat
NewLocation = RandomLocations:FindFirstChild(math.random(1,12))
wait()
until
NewLocation ~= RandomLocation
end
Path:ComputeAsync(HumanoidRootPart.Position, NewLocation.Position)
local Waypoints = Path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid.MoveToFinished:Wait(2)
Humanoid:MoveTo(waypoint.Position)
end
end
end)
local ProximityPrompt = HumanoidRootPart:WaitForChild("ProximityPrompt")
local PetAnimationActivated = ReplicatedStorage:WaitForChild("RemoteEvents").PetAnimationActivated
ProximityPrompt.Triggered:Connect(function(Player)
ProximityPrompt.Enabled = false
Stop = true
PetAnimationActivated:FireClient(Player)
Humanoid:MoveTo(HumanoidRootPart.Position)
local ShrekStats = Player:WaitForChild("ShrekStats")
local HappinessStat = ShrekStats:WaitForChild("Happiness")
if HappinessStat.Value <= 40 then
HappinessStat.Value = HappinessStat.Value + 20
else
local ValueTo100 = 100-HappinessStat.Value
HappinessStat.Value = HappinessStat.Value + ValueTo100
end
end)
PetAnimationActivated.OnServerEvent:Connect(function()
Stop = false
Humanoid:MoveTo(RandomLocation.Position)
ProximityPrompt.Enabled = true
end)
[quote="Pain, post:1, topic:2653966, full:true, username:TobiElReyofficial758"]
```local PathFindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local Shrek = workspace:WaitForChild("Shrek")
local HumanoidRootPart = Shrek:WaitForChild("HumanoidRootPart")
local Humanoid = Shrek:WaitForChild("Humanoid")
local Locations = script.Parent
local RandomLocations = Locations:WaitForChild("RandomLocations")
local FoodBowl = Locations:WaitForChild("FoodBowl")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LowHunger = ReplicatedStorage:WaitForChild("RemoteEvents").LowHunger
local Path = PathFindingService:CreatePath()
local RandomLocation = RandomLocations:FindFirstChild(math.random(1,12))
Path:ComputeAsync(HumanoidRootPart.Position, RandomLocation.Position)
local Waypoints = Path:GetWaypoints()
Humanoid:MoveTo(RandomLocation.Position)
local MoveRandomly = true
local Stop = false
local Hunger
Humanoid.MoveToFinished:Connect(function(RandomLocation)
LowHunger.Event:Connect(function(Player)
Hunger = Player:WaitForChild("ShrekStats").Hunger
if FoodBowl.FoodInBowl.Value == true then
MoveRandomly = false
Humanoid:MoveTo(FoodBowl.Position)
end
end)
if MoveRandomly == true and Stop == false then
wait(math.random(1,5))
local NewLocation
do repeat
NewLocation = RandomLocations:FindFirstChild(math.random(1,12))
wait()
until
NewLocation ~= RandomLocation
end
Path:ComputeAsync(HumanoidRootPart.Position, NewLocation.Position)
local Waypoints = Path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid:MoveTo(waypoint.Position)
end
elseif MoveRandomly == false and Stop == false then
Hunger.Value = 100
FoodBowl.FoodInBowl.Value = false
TweenService:Create(FoodBowl.Food, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1}):Play()
MoveRandomly = true
FoodBowl.Food.ParticleEmitter.Enabled = true
wait(1)
Hunger.Value = 100
wait(1)
Hunger.Value = 100
wait(1)
Hunger.Value = 100
FoodBowl.Food.ParticleEmitter.Enabled = false
local NewLocation
do repeat
NewLocation = RandomLocations:FindFirstChild(math.random(1,12))
wait()
until
NewLocation ~= RandomLocation
end
Path:ComputeAsync(HumanoidRootPart.Position, NewLocation.Position)
local Waypoints = Path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid.MoveToFinished:Wait(2)
Humanoid:MoveTo(waypoint.Position)
end
end
end)
local ProximityPrompt = HumanoidRootPart:WaitForChild("ProximityPrompt")
local PetAnimationActivated = ReplicatedStorage:WaitForChild("RemoteEvents").PetAnimationActivated
ProximityPrompt.Triggered:Connect(function(Player)
ProximityPrompt.Enabled = false
Stop = true
PetAnimationActivated:FireClient(Player)
Humanoid:MoveTo(HumanoidRootPart.Position)
local ShrekStats = Player:WaitForChild("ShrekStats")
local HappinessStat = ShrekStats:WaitForChild("Happiness")
if HappinessStat.Value <= 40 then
HappinessStat.Value = HappinessStat.Value + 20
else
local ValueTo100 = 100-HappinessStat.Value
HappinessStat.Value = HappinessStat.Value + ValueTo100
end
end)
PetAnimationActivated.OnServerEvent:Connect(function()
Stop = false
Humanoid:MoveTo(RandomLocation.Position)
ProximityPrompt.Enabled = true
end)```