Me crying because it's wrong and it's exact and a couple hours later I relise it was capitalization
@MrDiceZack2 жыл бұрын
Me when you can just copy the script in the description
@BeanieOSC2 жыл бұрын
@@MrDiceZack it’s worse because it didn’t even work
@explox21652 жыл бұрын
Thank you! I've been trying to find something like this, and now I can continue working on my game!
@Veraxil9 ай бұрын
thanks thanks thanks a lot everytime i try to found a pathfinding tutorial and i think this is the better one i saw
@inabsurd572 жыл бұрын
-- Variables local Pathfinding = game:GetService ("PathfindingService") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local path = Pathfinding:CreatePath({ AgentHeight = 6; AgentRadius = 3; AgentCanJump = false; -- Change "False" to "True" if you want your NPC to jump, if you don't want it to jump, vice versa Costs = { Water = 100; DangerZone = math.huge } }) local Character = script.Parent local humanoid = Character:WaitForChild("Humanoid") local waypoints local nextWaypointIndex local reachedConnection local blockedConnection local function findTarget () local maxDistance = 500 local nearestTarget for index, player in pairs(Players:GetPlayers()) do if player.Character then local target = player.Character local distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude if distance < maxDistance then nearestTarget = target maxDistance = distance end if distance < 5 then nearestTarget.Humanoid:TakeDamage (25) -- Change numeral to modify the damage taken from the NPC end end end return nearestTarget end local function followPath(destination) local success, errorMessage = pcall(function() path:ComputeAsync(Character.PrimaryPart.Position, destination) end) if success and path.Status == Enum.PathStatus.Success then waypoints = path:GetWaypoints () blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex) if blockedWaypointIndex >= nextWaypointIndex then blockedConnection:Disconnect() followPath(destination) end end) if not reachedConnection then reachedConnection = humanoid.MoveToFinished:Connect(function(reacjed) if reached and nextWaypointIndex < #waypoints then nextWaypointIndex += 1 humanoid:MoveTo(waypoints[nextWaypointIndex].Position) else reachedConnection:Disconnect() blockedConnection:Disconnect() end end) end nextWaypointIndex = 2 humanoid:MoveTo(waypoints[nextWaypointIndex].Position) else warn("Path not computed!", errorMessage) end end while wait() do local target = findTarget() if target then print(target.Name) followPath(target.HumanoidRootPart.Position) end end local npcRootPart = NPC.HumanoidRootPart npcRootPart:SetNetworkOwner(nil)
@felizen2 жыл бұрын
thank you :D
@nika1506n02 жыл бұрын
thanks
@HDIsReal2 жыл бұрын
true hero
@encantle9580 Жыл бұрын
life saver
@DEMONgames7058 ай бұрын
thx
@lav98022 жыл бұрын
Best video! I’m trying to find developers lol
@cheemsdrip74782 жыл бұрын
this is off topic, but i despise the new icons. and we used to have the option to use the older (and superior) icons but now that option is gone, and were stuck with the horrible simplified icons. i also heard that they are really hard to see if you have a vision disability.
@TomBuilds2 жыл бұрын
My opinion is that they look kind of modern, but I agree. There should be an option to switch. I think RoBuilder does a video on how to change it. And having icons that are really hard to see if you have a vision disability is ridiculous. They should definitely have an option to change it. :D
@WimVanhaeren-xt3yo10 ай бұрын
Thanks a lot for this! But the NPC is the same speed as you, how can you make him a little bit slower?
@FavouredPrince10 ай бұрын
go to the npc then humanoid then walkspeed then u can change it
@Ra1nV1 Жыл бұрын
How come when the creature kills a player, when the player respawns, the creature won't attack again? I'm confused
@david_lynne Жыл бұрын
11:29 I left here
@storylynnegoss15655 ай бұрын
is there something that you can change like making certain NPCS to go to certain waypoints?
@happyduck14242 жыл бұрын
I like this video, only thing I wish you explained more of how the pathfinding services works in totality, lucky this isn't my first Ai.
@TomBuilds2 жыл бұрын
I might do a video on Pathfinding NPCs. 👍
@overlord27542 жыл бұрын
@@TomBuilds bro help please it says in output "Path not computed! Workspace. .Mainscript:52 attempt to index nil with 'Position' - Server" how do I fix it
@TomBuilds2 жыл бұрын
I’m thinking of doing a stream where I help everyone out with Pathfinding since it’s quite a complicated topic. 👍
@OfficialAviguetero2 жыл бұрын
@@TomBuilds hey can you help me i copied what you did when i test it the npc is not walking i carefully watched all the steps but it's not working what am i missing :(?
@3qrb__10 ай бұрын
did you find anything?@@OfficialAviguetero
@bibstyr2 жыл бұрын
help, even if i set the network owner of the hrp to nil, he is still laggy and has a seizure every time he tries to walk
@quackers5192 жыл бұрын
Almost forgot runservice existed. I’m an actual game & software developer. Tried out lua, found Roblox, and now I’m here.
@TomBuilds2 жыл бұрын
Glad to hear it! The coming to Roblox, not the forgetting of the Run Service. 😂👍
@Normal-editz2 жыл бұрын
Wait do we have to do 1:18 through 12:18 or does the animation thing do it by its self pls reply
@TomBuilds2 жыл бұрын
The idle animation of the NPC should work regardless of the “follow” script. 👍
@nika1506n02 жыл бұрын
@@TomBuilds you must put the script in comments
@Forgottenace92 жыл бұрын
If anyone wants him to jump if required, paste this thing after each :MoveTo() and set AgentCanJump to true if waypoints[nextWaypointIndex].Action == Enum.PathWaypointAction.Jump then humanoid.Jump = true end
@DanielPlaysBlox2 жыл бұрын
what line should i paste it?
@Forgottenace92 жыл бұрын
@@DanielPlaysBlox after each line that includes :MoveTo()
@dilutedue2 жыл бұрын
@@Forgottenace9 when it jumps into another platform it cant get down bruh
@Forgottenace92 жыл бұрын
@@dilutedue Yeah Roblox' original pathfinding system with jumping might be laggy, so I suggest making your own. But it's not that easy and requires some skill in math and Lua.
@basicallyGuestcorn Жыл бұрын
@@dilutedue When it was up there when it jumps it will just move back like it was scared of the damn heights
@salemalmari2008 Жыл бұрын
Does he get damage when i shoot him?
@Revadow5632 жыл бұрын
If we are allowed to suggest videos, are you able to make a video on a Sprint button with Stamina for Mobile? I've been struggling with coming up with a Script for this.
@glugluglupsdevteam Жыл бұрын
Hi everyone out there, if you guys are lazy like me, you can copy the code, I think it works fine, please tell me if there is any issue! (Script:) local PathFinding = game:GetService("PathfindingService") local Player = game:GetService("Players") local Run = game:GetService("RunService") local Path = PathFinding:CreatePath({AgentHeight = 6; AgentRadius = 4; AgentCanJump = false; Costs = {Water = 100, DangerZone = math.huge}}) local Character = script.Parent local Humanoid = Character:WaitForChild("HumanPiggy") local WayPoints local NextWayPointIndex local ReachedConnection local BlockedConnection local function FindTarget() local MaxDistance = 500 local NearestTarget for index, Player in pairs(Player:GetPlayers()) do if Player.Character then local target = Player.Character local Distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude if Distance < MaxDistance then NearestTarget = target MaxDistance = Distance end if Distance < 3 then NearestTarget.Humanoid:TakeDamage(30) end end end return NearestTarget end local function FollowPath(destination) local Success, errorMessage = pcall(function() Path:ComputeAsync(Character.PrimaryPart.Position, destination) end) if Success and Path.Status == Enum.PathStatus.Success then WayPoints = Path:GetWaypoints() BlockedConnection = Path.Blocked:Connect(function(BlockedWayPointIndex) if BlockedWayPointIndex >= NextWayPointIndex then BlockedConnection:Disconnect() FollowPath(destination) end end) if not ReachedConnection then ReachedConnection = Humanoid.MoveToFinished:Connect(function(reached) if reached and NextWayPointIndex < WayPoints then NextWayPointIndex += 1 Humanoid:MoveTo(WayPoints[NextWayPointIndex].Position) else ReachedConnection:Disconnect() BlockedConnection:Disconnect() end end) end NextWayPointIndex = 2 Humanoid:MoveTo(WayPoints[NextWayPointIndex].Position) else warn("Path not Computed!", errorMessage) end end while wait() do local Target = FindTarget() if Target then print(Target.Name) FollowPath(Target.HumanoidRootPart.Position) end end
@lakilled1486 Жыл бұрын
i love u
@glugluglupsdevteam Жыл бұрын
lol, np, always helping!@@lakilled1486
@imbryanyt4569 ай бұрын
i love you
@p0gg_man9657 ай бұрын
i love you
@storylynnegoss15655 ай бұрын
Glug you are a hero
@justvoise2 жыл бұрын
Yes finally, A good series to make my scary game. I tried finding one for months but those did not work. Thank you!
@obligeon2 жыл бұрын
very true bro
@x1x1x1gamer2 жыл бұрын
Does everything need to be the same like the capitols?
@TomBuilds2 жыл бұрын
Depending on what it is, yes. But, to be safe, I would keep it the same. 👍
@Kylerisano2 жыл бұрын
You can remove and insert a separate damage script if you don't the hitboxes to be so big.
@dittyuu2 жыл бұрын
Or you could make the number smaller
@austinwhiteted8231 Жыл бұрын
@@dittyuu😂😂
@austinwhiteted8231 Жыл бұрын
I was gonna say that
@IDcLuc Жыл бұрын
Hello! This works amazingly, but I get the error ` 12:16:55.617 Workspace.Bellany.Scripts.Pathfinding:56: attempt to index boolean with 'Disconnect' - Server - Pathfinding:56` when I jump over the ghosts head. Is there any way to fix this?
@TomBuilds Жыл бұрын
Not sure. I would just remove the ability to jump. 👍
@IDcLuc Жыл бұрын
@@TomBuilds Makes sense to have jumping disabled in a horror game and it still works after getting the error either way so yeah, I'll just disable jumping.
@Darius_032 жыл бұрын
Thanks a ton, you've earned a sub
@CubeHeddiX4 ай бұрын
What about custom npc for horror games? Like you build characters with shapes.
@Aarush_mala2 жыл бұрын
Part three jumpscare animation
@dragonite4 Жыл бұрын
the pathfinding thing means where the npc knows where he's going for a smart ai
@DAYCAT5672 ай бұрын
What exactly does the Costs part do?
@FORRT95132 жыл бұрын
Where do you find the build rig
@nika1506n0 Жыл бұрын
just click "AVATAR"
@arza37169 ай бұрын
A problem I came across with was that I wouldn’t would through doorways. To fix this just decreases the radius
@Werteux2 жыл бұрын
Is there a way to prevent him from seeing you behind the object, only when you enter the prison field will he notice you and start chasing you, and when you hide or run away he will stop chasing you
@TomBuilds2 жыл бұрын
I am going to work on an updated version, which will include the solution to this problem. 👍
@Werteux2 жыл бұрын
@@TomBuilds Thank You!!!!!!
@ascendedreality85462 жыл бұрын
Raycast from your npcs head to any players it "sees" head and if theirs an obstruction make it cancel its detection of that player.
@Werteux2 жыл бұрын
@@ascendedreality8546 How to do it?
@ascendedreality85462 жыл бұрын
@@Werteux Do you not know how to raycast?
@qlvxzz2 жыл бұрын
THANK YOU! I have been dreading the moment where I would have to add this because my experience with Pathfinding is not nice. But you made it so easy and simple! Again, Thank You ! Also Here is the properly functional script because I saw some people giving it out but it wasn't correct. NOTE* - You will need to change certain things such as height and radius as well as the follow distance. local Pathfinding = game:GetService("PathfindingService") local Player = game:GetService("Players") local RunService = game:GetService("RunService") local path = Pathfinding:CreatePath({ AgentHeight = 24; AgentRadius = 24; AgentCanJump = false; Costs = { Water = 100; DangerZone = math.huge } }) local Character = script.Parent local humanoid = Character:WaitForChild("Humanoid") local waypoints local nextWaypointIndex local reachedConnection local blockedConnection local function findTarget() local maxDistance = 600 local nearestTarget for index, player in pairs(Player:GetPlayers()) do if player.Character then local target = player.Character local distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude if distance < maxDistance and target.Humanoid.Health > 0 then nearestTarget = target maxDistance = distance end if distance < 5 then nearestTarget.Humanoid:TakeDamage(1000000000) end end end return nearestTarget end local function followPath(destination) local success, errorMessage = pcall(function() path:ComputeAsync(Character.PrimaryPart.Position, destination) end) if success and path.Status == Enum.PathStatus.Success then waypoints = path:GetWaypoints() blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex) if blockedWaypointIndex >= nextWaypointIndex then blockedConnection:Disconnect() followPath(destination) end end) if not reachedConnection then reachedConnection = humanoid.MoveToFinished:Connect(function(reached) if reached and nextWaypointIndex < #waypoints then nextWaypointIndex += 1 humanoid:MoveTo(waypoints[nextWaypointIndex].Position) else reachedConnection:Disconnect() blockedConnection:Disconnect() end end) end nextWaypointIndex = 2 humanoid:MoveTo(waypoints[nextWaypointIndex].Position) else warn("Path not computed!", errorMessage) end end while wait() do local target = findTarget() if target then print(target.Name) followPath(target.HumanoidRootPart.Position) end end
@TomBuilds2 жыл бұрын
I'm so happy that I could help. 👍
@GodzillaJawz Жыл бұрын
@@TomBuilds could you do one with line of sight / ray casting?
@TomBuilds Жыл бұрын
There is one. Check my Hello Neighbor NPC video. 👍
@fitrirachmawati7730 Жыл бұрын
Thank with the code
@fitrirachmawati7730 Жыл бұрын
Now i dont cry because my dead fingers
@OhHaiC Жыл бұрын
Can you make it so even if the path is blocked by something it'll just keep hugging the wall or the thing that is blocking its way instead of saying the error message? i have a script that if the npc aka monster touches a certain part it'll start breaking it until he gets through (cuz i put health on my parts), would be happy if you could help! :)
@grandpas-stuff Жыл бұрын
still need some help?
@thechannel79882 жыл бұрын
can you create a monster that randomly attacks the player like Charles from "Choo Choo Charles" I understand that this game was made on a different game creation engine, but if possible, please do a tutorial on this
@Werteux Жыл бұрын
Hi Tom, do you know how I can make time interval from hitting an enemy? Because one second if I touch it, I'm dead.
@bober10082 жыл бұрын
Hey i have an issue cuz ai is not working I keep getting error message part not computed. What should i do?
@RaanuAli47 Жыл бұрын
ask chatgbt (dont actually hes keep giving me wrong scripts that dont work)
@MydroPunk Жыл бұрын
why wont it animate for me?
@DanielPlaysBlox2 жыл бұрын
How can i make the npc jump?
@noahh_ Жыл бұрын
Is there a way to add a wander/patrol feature to it?
@renklad Жыл бұрын
thx man finally a smart killer that does not get stuck in walls
@yoyojonas Жыл бұрын
Hello please help me my Npc stops run after me after it has killed me once please tell me if you find a fix
@Ballistic_Missile.2 жыл бұрын
Can you PLEASE put a link so i can copy the script? please
@fns7629 Жыл бұрын
can you put a link for the plugin? i dont have it
@secretmarmenus Жыл бұрын
how do i make it detect if its not chasing the player anymore?
@NemoDpro2 жыл бұрын
Finally the thing I wanted
@CadeRankin200611 ай бұрын
Im having problems with my dude he keeps getting stuck on the walls and im looking at the script and it says - - WATCH THE VIDEO IF STUCK but i can’t see anything…
@starzzanaa Жыл бұрын
I didn't see the MainScript on the desc so I just wrote this one just 4 the people who needs it! -- variables -- local PathFinding = game:GetService("PathFindingService") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local path = PathFinding:CreatePath({ AgentHeight = 6; AgentRadius = 3; AgentCanJump = false; Costs = { Water = 100; DangerZone = math.huge } }) local Character = script.Parent local humanoid = character:WaitForChild("Humanoid") local waypoints local nextWaypointIndex local reachedConnection local blockedConnection local function findTarget() local maxDistance = 1000 local nearestTarget for index, player in pairs(Players:GetPlayers()) do if player.Character then local target = player.Character local distance = (Character.HumanoidRootPart.Position -target.HumanoidRootPart.Position).Magnitude if distance < maxDistance then nearestTarget = target maxDistance = distance end if distance < 2 then nearestTarget.Humanoid:TakeDamage(10) end end end return nearestTarget end local function followPath(destination) local success, errorMessage = pcall(function() path:ComputeAsync(Character.PrimaryPart.Position, destination) end) if success and pathStatus == Enum.PathStatus.Success then wayPoints = path:GetWaypoints blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex) if blockedWaypointIndex >= nextWaypointIndex then blockedConnection:Disconnect() followPath(destination) end end) if not reachedConnection then reachedConnection = humanoid.MoveToFinished:Connect(function(reached) if reached and nextWaypointIndex < #wayPoints then nextWaypointIndex += 1; humanoid.MoveTo(wayPoints [nextWaypointIndex].Position) else reachedConnection:Disconnect() blockedConnection:Disconnect() end end) end nextWaypointIndex = 2 humanoid:MoveTo(wayPoints[nextWaypointIndex].Position) else warn("Path not computed!", errorMessage) end end while wait() do local target = findTarget() if target then print(target.Name) followPath(target.HumanoidRootPart.Position) end end
@ImaginationRealm232 Жыл бұрын
W
@JosephBriggs-eq6db5 ай бұрын
i get an error saying Workspace.Killer.MainScript:11: Expected ',' after table constructor element. What do i do?
@aobrienrich26722 жыл бұрын
3:20 timestamp
@TheRealMaksimus Жыл бұрын
Sometimes npc stops and can't compute the path. How to fix it?
@NuggetCraft Жыл бұрын
can you send a link of the plugin u used to create the rig?
@srshivam968 ай бұрын
thats default
@couchwow2 жыл бұрын
Is there a way to make the creature wander to specific spots after it has killed you? I want to make a creature that wanders to specific spots and chases you if you run into it.
@TomBuilds2 жыл бұрын
I’ll look into doing that. 👍
@couchwow2 жыл бұрын
@@TomBuilds Please do! Thank you!
@crazycarrot638711 ай бұрын
When I die and respawn, the monster no longer will target me?
@0_0fakei18 Жыл бұрын
theres a problem, looks like the npc just stops when the player is in a higher or a lower level of the npc
@IJWTFHWA Жыл бұрын
if you followed this script exactly it has jumping turned off
@s_x_9killer5272 жыл бұрын
can you make a video about pathfinding ai npc moves to waypoints if he sees you he attacks you
@ChazzysRoblox Жыл бұрын
If i go behind the creature it stop going after me
@Parkoury Жыл бұрын
Mine does not work and has an error saying " GetWayPoints is not a valid member of Path "Instance" "
@sync.0 Жыл бұрын
how do you make it so the AI doesnt go to a certain area on the baseplate, like for example the spawn point for players so it doesnt just spawn camp them
@mediocreatbest1269 Жыл бұрын
Why does the “Costs” part not work for me?
@PikiAnimates Жыл бұрын
The script keeps spamming "Path not computed! nil" and it makes the npc act really funk. how do I fix this?
@Ari_Allstar2 жыл бұрын
when i add the follow path to the humanoidrootpart it says it cant do it bec its a table value is there any way to fix this?
@TomBuilds2 жыл бұрын
I haven't heard of that problem before. Try playing around with the code some more. That's what I always do. 👍
@CalixReyes Жыл бұрын
mine doesnt work for some reason it just says GetWaypoint is not a valid member of Path "Instance"
@mathiazscp2 жыл бұрын
Hey, I know this might be a dumb question, but does it have to be R6 or R15?
@TomBuilds2 жыл бұрын
I used R15. I haven’t tested with R6 so not sure. 👍
@mathiazscp2 жыл бұрын
@@TomBuilds Thank you for answering!
@rileylecaptain1132 жыл бұрын
you can use it for r6, i made a nextbot game and in order to dave storage space on the game to not be laggy i made it r6
@jaydenbaker6311 Жыл бұрын
How do you make them go by sight
@Oli33-j5j Жыл бұрын
is there a way you could copy and paste it into desc cuz i dont have time to write all that pls
@Oli33-j5j Жыл бұрын
ill sub?
@Michalien112 Жыл бұрын
How to make him jump, and how to make him detect people above him?
@MsSanjum Жыл бұрын
Why didn't you tell us to anchor and unachor right before u tested? i deleted the script and now i have to spend another hour re writing it!
@TomBuilds Жыл бұрын
I do say it in more recent videos. 👍
@9RBLX2 жыл бұрын
Does the script work for an R6 rig
@Blue-Coding Жыл бұрын
Thanks!
@CalypsoLemonade12 жыл бұрын
It doesnt move but when i touch it it kills me, how do i fix this?
@Forgottenace92 жыл бұрын
unanchor
@rileylecaptain1132 жыл бұрын
thats the thing when it doesn't detect the player it wouldn't move
@Vincent-dn8zj2 жыл бұрын
Hey. i copied the script perfectly but when the npc chases me it appears Path not computed nil, and it doesn't move or sometimes it tries to walk into the walls and act glitchy. but there are times when it works kind of fine. what could it be?
@Vincent-dn8zj2 жыл бұрын
@@NotLuhvash sadly it still happens
@ascendedreality85462 жыл бұрын
@@Vincent-dn8zj Thats because the code snippet he gave has nothing to do with the issue lmao. Your script is probably having an issue getting a player or npc.
@Areyouseriousrnbro2 жыл бұрын
@@Vincent-dn8zj Maybe check the agentheight and agentradius and add 1 or more.
@sussus58412 жыл бұрын
its the same for me but my npc wont ever move
@quackers5192 жыл бұрын
Remember what he does is not the most efficient. I’ve worked with c++ and c#. Try to understand how the code works, and how to make it better.
@ninjadj48262 жыл бұрын
i did exacly the exact same code but the dummy don't move it's making me sad, every time i copy a code it don't move
@basicallyGuestcorn Жыл бұрын
Because the dummy’s humanoidrootpart is anchored so always check if any parts of the character is anchored or it won’t move
@roninplayzandexperiments2327 Жыл бұрын
hey bro, is there a way to limit the npc's vision? because i want to make a stealth game that's inspired by metal gear
@TomBuilds Жыл бұрын
If you check out some of my newer AI videos, there should be something there. 👍
@selfwastaken2 жыл бұрын
Heres the script with NO errors or miss spellings, local Player = game:GetService("Players") local RunService = game:GetService("RunService") local pathFinding = game:GetService("PathfindingService") local path = pathFinding:CreatePath({ AgentHeight = 6; AgentRadius = 3; AgentCanJump = false; Costs = { Water = 100; DangerZone = math.huge } }) local Character = script.Parent local humanoid = Character:WaitForChild("Humanoid") local waypoints local nextWaypointIndex local reachedConnection local blockedConnection local function findTarget() local maxDistance = 600 local nearestTarget for index, player in pairs(Player:GetPlayers()) do if player.Character then local target = player.Character local distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude if distance < maxDistance and target.Humanoid.Health > 0 then nearestTarget = target maxDistance = distance end if distance < 5 then nearestTarget.Humanoid:TakeDamage(1000000000) end end end return nearestTarget end local function followPath(destination) local success, errorMessage = pcall(function() path:ComputeAsync(Character.PrimaryPart.Position, destination) end) if success and path.Status == Enum.PathStatus.Success then waypoints = path:GetWaypoints() blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex) if blockedWaypointIndex >= nextWaypointIndex then blockedConnection:Disconnect() followPath(destination) end end) if not reachedConnection then reachedConnection = humanoid.MoveToFinished:Connect(function(reached) if reached and nextWaypointIndex < #waypoints then nextWaypointIndex += 1 humanoid:MoveTo(waypoints{nextWaypointIndex}.Position) else reachedConnection:Disconnect() blockedConnection:Disconnect() end end) end nextWaypointIndex = 2 humanoid:MoveTo(waypoints[nextWaypointIndex].Position) else warn("Path not computed!", errorMessage) end end while wait() do local target = findTarget() if target then print(target.Name) followPath(target.HumanoidRootPart.Position) end end
@Rowinu2 жыл бұрын
ty
@CemBarlin_YT Жыл бұрын
Thaaaaaaaaaaaaaanks
@rhyswerner1748 Жыл бұрын
I’m looking for inspiration for my friend. I want to coax him into making a quick, short running/survival game where you just gotta run from a dangerous entity. So thanks!
@porta1master0962 жыл бұрын
so does this work like this: You hide Somewhere for example a Closet Will the Ai Walk Pass or will it just be stupid by running into the Closet
@TomBuilds2 жыл бұрын
Interesting question. I haven’t tried it out. Maybe give it a go and tell me. If it runs into the closet, I will try to improve it. 👍
@error9424 Жыл бұрын
Will it even matter if my game will get taken down from the makers of spongebob because i made a fan made horror game
@TomBuilds Жыл бұрын
I doubt that will happen. At least, I hope it won’t 😂😂
@error9424 Жыл бұрын
Wait a minute, why it when the code says if reached next
@p0gg_man9657 ай бұрын
Took a bit of tinkering but I got it. local PathFinding = game:GetService("PathfindingService") local Player = game:GetService("Players") local Run = game:GetService("RunService") local Path = PathFinding:CreatePath({AgentHeight = 6; AgentRadius = 4; AgentCanJump = false; Costs = {Water = 100, DangerZone = math.huge}}) local Character = script.Parent local Humanoid = Character:WaitForChild("Humanoid") local WayPoints local NextWayPointIndex local ReachedConnection local BlockedConnection local function FindTarget() local MaxDistance = 500 local NearestTarget for index, Player in pairs(Player:GetPlayers()) do if Player.Character then local target = Player.Character local Distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude if Distance < MaxDistance then NearestTarget = target MaxDistance = Distance end if Distance < 3 then NearestTarget.Humanoid:TakeDamage(30) end end end return NearestTarget end local function FollowPath(destination) local Success, errorMessage = pcall(function() Path:ComputeAsync(Character.HumanoidRootPart.Position, destination) end) if Success and Path.Status == Enum.PathStatus.Success then WayPoints = Path:GetWaypoints() BlockedConnection = Path.Blocked:Connect(function(BlockedWayPointIndex) if BlockedWayPointIndex >= NextWayPointIndex then BlockedConnection:Disconnect() FollowPath(destination) end end) if not ReachedConnection then ReachedConnection = Humanoid.MoveToFinished:Connect(function(reached) if reached and NextWayPointIndex < WayPoints then NextWayPointIndex += 1 Humanoid:MoveTo(WayPoints[NextWayPointIndex].Position) else ReachedConnection:Disconnect() BlockedConnection:Disconnect() end end) end NextWayPointIndex = 2 Humanoid:MoveTo(WayPoints[NextWayPointIndex].Position) else warn("Path not Computed!", errorMessage) end end while wait() do local Target = FindTarget() if Target then print(Target.Name) FollowPath(Target.HumanoidRootPart.Position) end end
@beedown6 ай бұрын
thx man
@FootySubject Жыл бұрын
What if we choose to swim?
@tekoolll Жыл бұрын
thank you, but if you try to make the npc go up a wedge/stairs. it'll just go near it but it'll not try to go up. is there any fix?
@zaxhir Жыл бұрын
use a ramp and make it transparent
@basicallyGuestcorn Жыл бұрын
It works, but when I was on a high place with a stair, it gives up
@AhkrisAF Жыл бұрын
Now that I understand Lua script, I can do what I want
@Cojo_Catarou2 жыл бұрын
Me making this entire script and messing up one word by not capitalizing it
@TomBuilds2 жыл бұрын
I’ve done the same. 😂
@CubeHeddiX4 ай бұрын
Also custom animations.
@crystalwyrm4767 Жыл бұрын
what would I do if I wanted it to be like a tower defense game?
@xyz0138 Жыл бұрын
For some reason, it works fine but after like 10 seconds it stops
@RuiraMEOW2 жыл бұрын
I'm sorry for this question but why my monster becomes invisible? Well it attacks, but it's invisible, what do I do?
@TomBuilds2 жыл бұрын
Make sure you set all of the body parts' transparency to 0. Other than that, I'm not sure. :D
@RuiraMEOW2 жыл бұрын
@@TomBuilds Okay, ty for answering!
@Mr.ChickenOfficialYT Жыл бұрын
How do I make it so that it just walks around aimlessly when a player is not in range
@TomBuilds Жыл бұрын
Check one of my latest pathfinding videos. Should be there. 👍
@Mr.ChickenOfficialYT Жыл бұрын
@@TomBuilds Ok thanks
@z_tock2 жыл бұрын
None of these videos work for me and yet again it didnt work didnt even print my name in output
@mjak537 Жыл бұрын
I did everything in the video and It doesn't seem to be working.
@MegaVranjanac2 жыл бұрын
My npc doesnt rotate at path any suggestions?
@rileylecaptain1132 жыл бұрын
how do you make it so when it dosn't know where a player is it would randomly wander
@TomBuilds2 жыл бұрын
I have an updated video on this. Check my channel for a similar video. 👍
@rileylecaptain1132 жыл бұрын
@@TomBuilds thanks you
@djole_grobar2 жыл бұрын
i wasted 2 hours typing the code and doesnt work. idk if i typed a line of code wrong. im not sure
@TomBuilds2 жыл бұрын
Make sure to check for spelling mistakes and unnecessary capitulation, or necessary capitulation. 👍
@anime5954 Жыл бұрын
It worked the first time but then i cut the script accidently and now it won't work.
@dianamazzei83162 жыл бұрын
my rig is just floating why?
@RodsterInk2 жыл бұрын
try anchoring it then unanchoring it. There might be a part that's anchored so the entire thing just kind of Stands there
@happy-day_30002. Жыл бұрын
it doesn't work for me i think its outdated or something
@callmeghst65422 жыл бұрын
Is there a way to make it have a short delay whenever it attacks again, since I don’t want it to attack right after it hits
@TomBuilds2 жыл бұрын
You could put a “wait(2)” in front of where it attacks you. 👍
@callmeghst65422 жыл бұрын
@@TomBuilds ok nvm I fixed the wait. I just added a debounce and now it works. But still tryna figure out the can jump thing
@TomBuilds2 жыл бұрын
If you want them to jump, just set the “AgentCanJump” to “true”. 👍
@Areyouseriousrnbro2 жыл бұрын
@@TomBuilds i added debounce to add a delay, but is there anyway to make it so it continues moving after each hit. After it attacks it just stops moving for 2 seconds. I want it to move while there is a delay.
@pelsckopolesko Жыл бұрын
Can you make it so when he can’t see you, he will stop chasing you?