#how do i fix this bug

78 messages · Page 1 of 1 (latest)

clear hamlet
#
                seentarget = false
                print("no target")
                if script.Parent.HumanoidRootPart.Chase.IsPlaying == true then
                    coroutine.wrap(function()
                        for i=1,10 do
                            script.Parent.HumanoidRootPart.Chase.Volume *= 0.9
                        end
                        script.Parent.HumanoidRootPart.Chase:Stop()
                    end)()
                end
                script.Parent.Humanoid.WalkSpeed = 15
                script.Parent.Humanoid:MoveTo(waypoint.Position)
                script.Parent.Humanoid.MoveToFinished:Wait()
#

this is the whole script when monster doesnt see or is wandering

native tundra
#

ok?

#

and?

clear hamlet
#

wat

native tundra
#

u didnt tell us what bug ur trynna fix, what solutions u tried and didnt work, whether u did ur research, whats the expected behaviour, what is the actual behaviour, how the unexpected behaviour is replicated, etc etc

#

if i said "help how do i fix this" and post a random video and code that seems to work what would you tell me

native tundra
clear hamlet
#

u didnt look at the video

native tundra
clear hamlet
#

yes

#

in the end the bug occurs

native tundra
#

do u not want it to chase u

clear hamlet
#

what

native tundra
#

whats happening that u dont want to happen lol

#

and what solutions did u try

clear hamlet
#

the bug??

native tundra
#

👋

clear hamlet
#

he literally

#

hugs the wall

#

in the end of the video

native tundra
#

u gotta realise that i cant read your mind to tell what u expect it to do

#

and what solutions u tried

native tundra
clear hamlet
native tundra
#

lemme just ask, why are u using coroutine.wrap in the code

clear hamlet
#

i mean i cant even try any other solutions as i dont know why it occurs

clear hamlet
native tundra
#

right but why are you wrapping the function

clear hamlet
#

wdym

#

to not interupt the whole pathfinding system???

#

aka moving to waypoint and another

native tundra
#

u should know that u do interrupt the code regardless

#

coroutine doesnt utilise multithreadding

#

from what i remember at least

#

i think whats happening is he is trying to get to the start position @clear hamlet

#

do u expect him to stand in place after chasing you or do u expect him to return where he was

clear hamlet
#

wat start position

native tundra
#

where he was standing at first

native tundra
clear hamlet
#

idk why he hugs to the wall tho

#

its not like im using a regular moveto instead of pathfinding

native tundra
#

because the wall is in the way

clear hamlet
#

Yeah but

#

pathfinding specifically exists for that

native tundra
clear hamlet
#

so ai wont hug the wall

clear hamlet
native tundra
#

yes thats exactly what u did tho

clear hamlet
#

no

native tundra
#

second to last line

clear hamlet
#
function GetWaypoints(wheretogo)
    local path = GetPath(wheretogo)
    if path.Status == Enum.PathStatus.Success then
        for i, waypoint in pairs(path:GetWaypoints()) do
            local target = FindTarget()
            if target and target:WaitForChild("Humanoid").Health ~= 0 then
                script.Parent.Humanoid.WalkSpeed = 27
                Attack(target)
                seentarget = true
                break
            else
                seentarget = false
                print("no target")
                if script.Parent.HumanoidRootPart.Chase.IsPlaying == true then
                    script.Parent.HumanoidRootPart.Chase:Stop()
                end
                script.Parent.Humanoid.WalkSpeed = 15
                script.Parent.Humanoid:MoveTo(waypoint.Position)
                script.Parent.Humanoid.MoveToFinished:Wait()
            end
        end
    else
        warn("ERROR")
    end
end
native tundra
clear hamlet
#

forgot i didnt include pathfinding

#

sorry

#

dont know why it happens tho

#

cuz it uses pathfinding

native tundra
#

does moveto just move in a straight line regardless of walls ahead or does it utilize roblox pathfinding

native tundra
#

strange

clear hamlet
#
function GetPath(wheretogo, target, useparams)
    local pathParams
    if not useparams then
        pathParams = {
            ["AgentHeight"] = 8,
            ["AgentRadius"] = 4,
            ["AgentCanJump"] = true,
            ["AgentCanClimb"] = true
        }
    end
    local path = pathfinding:CreatePath(pathParams)
    path:ComputeAsync(script.Parent.HumanoidRootPart.Position, wheretogo)
    path.Blocked:Connect(function(blockedWaypointIdx)
        if not target then
            local allwaypoints = workspace.Waypoints:GetChildren()
            local random = math.random(1, #allwaypoints)
            repeat
                task.wait()
            until random ~= currentIndex
            currentIndex = random
            path:ComputeAsync(script.Parent.HumanoidRootPart.Position, allwaypoints[random])
            return path
        else
            path:ComputeAsync(script.Parent.HumanoidRootPart.Position, target.PrimaryPart.Position)
        end
    end)
    return path
end
#

make path function

#

i mean

#

get path

native tundra
#

can u check where the path is by making a temporary part to see it

#

just make sure the path really isnt in the wall

clear hamlet
#

ok

#

wait actually

#

cant i just use navmesh

#

thats what it exactly does

native tundra
#

i dont know

#

u definitely can try though

clear hamlet
#

actually nvm it doesnt work