I’m making a escape game where this monster chases you through a maze and I’ve made a script where it detects players and chases them but the monster only follows the players previous position, this makes the monster extremely easy to dodge. I want it to continuously follow the player.
this is the code
``
if distance > 3 then
for index, waypoint in pairs(path:GetWaypoints()) do
local newTarget = findTarget()
if newTarget == target then
--checking waypoints
local part = Instance.new("Part", workspace)
part.CanCollide = false
part.Anchored = true
part.Position = waypoint.Position
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
elseif newTarget ~= target then
--there are closer targets! switch!
path = getPath(newTarget.HumanoidRootPart)
else
break
end
end
else
--monster.Head.JumpScare:Play()
--local playerDeath = game.ReplicatedStorage.Events:WaitForChild("playerDeath")
--local player = game.Players:GetPlayerFromCharacter(target)
--playerDeath:FireClient(player, monster)
--local attackAnim = humanoid:LoadAnimation(script.Attack)
--attackAnim:Play()
--attackAnim.Stopped:Wait()
--target.Humanoid.Health = 0
end
``
yeah this was supposed to be in a function but roblox refuses to make that part of the code