How To Make A ROBLOX Horror Game - 1# Pathfinding AI

  Рет қаралды 75,410

Tom Builds

Tom Builds

Күн бұрын

Пікірлер: 361
@BeanieOSC
@BeanieOSC 2 жыл бұрын
Me after the scripts:crying about my dead fingers
@gamingon6158
@gamingon6158 2 жыл бұрын
Yes
@UniqueName-
@UniqueName- 2 жыл бұрын
U get dead fingers I'm used to it
@lumon.1
@lumon.1 2 жыл бұрын
Me crying because it's wrong and it's exact and a couple hours later I relise it was capitalization
@MrDiceZack
@MrDiceZack 2 жыл бұрын
Me when you can just copy the script in the description
@BeanieOSC
@BeanieOSC 2 жыл бұрын
@@MrDiceZack it’s worse because it didn’t even work
@explox2165
@explox2165 2 жыл бұрын
Thank you! I've been trying to find something like this, and now I can continue working on my game!
@Veraxil
@Veraxil 9 ай бұрын
thanks thanks thanks a lot everytime i try to found a pathfinding tutorial and i think this is the better one i saw
@inabsurd57
@inabsurd57 2 жыл бұрын
-- 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)
@felizen
@felizen 2 жыл бұрын
thank you :D
@nika1506n0
@nika1506n0 2 жыл бұрын
thanks
@HDIsReal
@HDIsReal 2 жыл бұрын
true hero
@encantle9580
@encantle9580 Жыл бұрын
life saver
@DEMONgames705
@DEMONgames705 8 ай бұрын
thx
@lav9802
@lav9802 2 жыл бұрын
Best video! I’m trying to find developers lol
@cheemsdrip7478
@cheemsdrip7478 2 жыл бұрын
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.
@TomBuilds
@TomBuilds 2 жыл бұрын
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-xt3yo
@WimVanhaeren-xt3yo 10 ай бұрын
Thanks a lot for this! But the NPC is the same speed as you, how can you make him a little bit slower?
@FavouredPrince
@FavouredPrince 10 ай бұрын
go to the npc then humanoid then walkspeed then u can change it
@Ra1nV1
@Ra1nV1 Жыл бұрын
How come when the creature kills a player, when the player respawns, the creature won't attack again? I'm confused
@david_lynne
@david_lynne Жыл бұрын
11:29 I left here
@storylynnegoss1565
@storylynnegoss1565 5 ай бұрын
is there something that you can change like making certain NPCS to go to certain waypoints?
@happyduck1424
@happyduck1424 2 жыл бұрын
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.
@TomBuilds
@TomBuilds 2 жыл бұрын
I might do a video on Pathfinding NPCs. 👍
@overlord2754
@overlord2754 2 жыл бұрын
@@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
@TomBuilds
@TomBuilds 2 жыл бұрын
I’m thinking of doing a stream where I help everyone out with Pathfinding since it’s quite a complicated topic. 👍
@OfficialAviguetero
@OfficialAviguetero 2 жыл бұрын
@@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__
@3qrb__ 10 ай бұрын
did you find anything?@@OfficialAviguetero
@bibstyr
@bibstyr 2 жыл бұрын
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
@quackers519
@quackers519 2 жыл бұрын
Almost forgot runservice existed. I’m an actual game & software developer. Tried out lua, found Roblox, and now I’m here.
@TomBuilds
@TomBuilds 2 жыл бұрын
Glad to hear it! The coming to Roblox, not the forgetting of the Run Service. 😂👍
@Normal-editz
@Normal-editz 2 жыл бұрын
Wait do we have to do 1:18 through 12:18 or does the animation thing do it by its self pls reply
@TomBuilds
@TomBuilds 2 жыл бұрын
The idle animation of the NPC should work regardless of the “follow” script. 👍
@nika1506n0
@nika1506n0 2 жыл бұрын
@@TomBuilds you must put the script in comments
@Forgottenace9
@Forgottenace9 2 жыл бұрын
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
@DanielPlaysBlox
@DanielPlaysBlox 2 жыл бұрын
what line should i paste it?
@Forgottenace9
@Forgottenace9 2 жыл бұрын
@@DanielPlaysBlox after each line that includes :MoveTo()
@dilutedue
@dilutedue 2 жыл бұрын
@@Forgottenace9 when it jumps into another platform it cant get down bruh
@Forgottenace9
@Forgottenace9 2 жыл бұрын
@@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
@basicallyGuestcorn Жыл бұрын
@@dilutedue When it was up there when it jumps it will just move back like it was scared of the damn heights
@salemalmari2008
@salemalmari2008 Жыл бұрын
Does he get damage when i shoot him?
@Revadow563
@Revadow563 2 жыл бұрын
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
@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
@lakilled1486 Жыл бұрын
i love u
@glugluglupsdevteam
@glugluglupsdevteam Жыл бұрын
lol, np, always helping!@@lakilled1486
@imbryanyt456
@imbryanyt456 9 ай бұрын
i love you
@p0gg_man965
@p0gg_man965 7 ай бұрын
i love you
@storylynnegoss1565
@storylynnegoss1565 5 ай бұрын
Glug you are a hero
@justvoise
@justvoise 2 жыл бұрын
Yes finally, A good series to make my scary game. I tried finding one for months but those did not work. Thank you!
@obligeon
@obligeon 2 жыл бұрын
very true bro
@x1x1x1gamer
@x1x1x1gamer 2 жыл бұрын
Does everything need to be the same like the capitols?
@TomBuilds
@TomBuilds 2 жыл бұрын
Depending on what it is, yes. But, to be safe, I would keep it the same. 👍
@Kylerisano
@Kylerisano 2 жыл бұрын
You can remove and insert a separate damage script if you don't the hitboxes to be so big.
@dittyuu
@dittyuu 2 жыл бұрын
Or you could make the number smaller
@austinwhiteted8231
@austinwhiteted8231 Жыл бұрын
​@@dittyuu😂😂
@austinwhiteted8231
@austinwhiteted8231 Жыл бұрын
I was gonna say that
@IDcLuc
@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
@TomBuilds Жыл бұрын
Not sure. I would just remove the ability to jump. 👍
@IDcLuc
@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_03
@Darius_03 2 жыл бұрын
Thanks a ton, you've earned a sub
@CubeHeddiX
@CubeHeddiX 4 ай бұрын
What about custom npc for horror games? Like you build characters with shapes.
@Aarush_mala
@Aarush_mala 2 жыл бұрын
Part three jumpscare animation
@dragonite4
@dragonite4 Жыл бұрын
the pathfinding thing means where the npc knows where he's going for a smart ai
@DAYCAT567
@DAYCAT567 2 ай бұрын
What exactly does the Costs part do?
@FORRT9513
@FORRT9513 2 жыл бұрын
Where do you find the build rig
@nika1506n0
@nika1506n0 Жыл бұрын
just click "AVATAR"
@arza3716
@arza3716 9 ай бұрын
A problem I came across with was that I wouldn’t would through doorways. To fix this just decreases the radius
@Werteux
@Werteux 2 жыл бұрын
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
@TomBuilds
@TomBuilds 2 жыл бұрын
I am going to work on an updated version, which will include the solution to this problem. 👍
@Werteux
@Werteux 2 жыл бұрын
@@TomBuilds Thank You!!!!!!
@ascendedreality8546
@ascendedreality8546 2 жыл бұрын
Raycast from your npcs head to any players it "sees" head and if theirs an obstruction make it cancel its detection of that player.
@Werteux
@Werteux 2 жыл бұрын
@@ascendedreality8546 How to do it?
@ascendedreality8546
@ascendedreality8546 2 жыл бұрын
@@Werteux Do you not know how to raycast?
@qlvxzz
@qlvxzz 2 жыл бұрын
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
@TomBuilds
@TomBuilds 2 жыл бұрын
I'm so happy that I could help. 👍
@GodzillaJawz
@GodzillaJawz Жыл бұрын
@@TomBuilds could you do one with line of sight / ray casting?
@TomBuilds
@TomBuilds Жыл бұрын
There is one. Check my Hello Neighbor NPC video. 👍
@fitrirachmawati7730
@fitrirachmawati7730 Жыл бұрын
Thank with the code
@fitrirachmawati7730
@fitrirachmawati7730 Жыл бұрын
Now i dont cry because my dead fingers
@OhHaiC
@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
@grandpas-stuff Жыл бұрын
still need some help?
@thechannel7988
@thechannel7988 2 жыл бұрын
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
@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.
@bober1008
@bober1008 2 жыл бұрын
Hey i have an issue cuz ai is not working I keep getting error message part not computed. What should i do?
@RaanuAli47
@RaanuAli47 Жыл бұрын
ask chatgbt (dont actually hes keep giving me wrong scripts that dont work)
@MydroPunk
@MydroPunk Жыл бұрын
why wont it animate for me?
@DanielPlaysBlox
@DanielPlaysBlox 2 жыл бұрын
How can i make the npc jump?
@noahh_
@noahh_ Жыл бұрын
Is there a way to add a wander/patrol feature to it?
@renklad
@renklad Жыл бұрын
thx man finally a smart killer that does not get stuck in walls
@yoyojonas
@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.
@Ballistic_Missile. 2 жыл бұрын
Can you PLEASE put a link so i can copy the script? please
@fns7629
@fns7629 Жыл бұрын
can you put a link for the plugin? i dont have it
@secretmarmenus
@secretmarmenus Жыл бұрын
how do i make it detect if its not chasing the player anymore?
@NemoDpro
@NemoDpro 2 жыл бұрын
Finally the thing I wanted
@CadeRankin2006
@CadeRankin2006 11 ай бұрын
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
@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
@ImaginationRealm232 Жыл бұрын
W
@JosephBriggs-eq6db
@JosephBriggs-eq6db 5 ай бұрын
i get an error saying Workspace.Killer.MainScript:11: Expected ',' after table constructor element. What do i do?
@aobrienrich2672
@aobrienrich2672 2 жыл бұрын
3:20 timestamp
@TheRealMaksimus
@TheRealMaksimus Жыл бұрын
Sometimes npc stops and can't compute the path. How to fix it?
@NuggetCraft
@NuggetCraft Жыл бұрын
can you send a link of the plugin u used to create the rig?
@srshivam96
@srshivam96 8 ай бұрын
thats default
@couchwow
@couchwow 2 жыл бұрын
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.
@TomBuilds
@TomBuilds 2 жыл бұрын
I’ll look into doing that. 👍
@couchwow
@couchwow 2 жыл бұрын
@@TomBuilds Please do! Thank you!
@crazycarrot6387
@crazycarrot6387 11 ай бұрын
When I die and respawn, the monster no longer will target me?
@0_0fakei18
@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
@IJWTFHWA Жыл бұрын
if you followed this script exactly it has jumping turned off
@s_x_9killer527
@s_x_9killer527 2 жыл бұрын
can you make a video about pathfinding ai npc moves to waypoints if he sees you he attacks you
@ChazzysRoblox
@ChazzysRoblox Жыл бұрын
If i go behind the creature it stop going after me
@Parkoury
@Parkoury Жыл бұрын
Mine does not work and has an error saying " GetWayPoints is not a valid member of Path "Instance" "
@sync.0
@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
@mediocreatbest1269 Жыл бұрын
Why does the “Costs” part not work for me?
@PikiAnimates
@PikiAnimates Жыл бұрын
The script keeps spamming "Path not computed! nil" and it makes the npc act really funk. how do I fix this?
@Ari_Allstar
@Ari_Allstar 2 жыл бұрын
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?
@TomBuilds
@TomBuilds 2 жыл бұрын
I haven't heard of that problem before. Try playing around with the code some more. That's what I always do. 👍
@CalixReyes
@CalixReyes Жыл бұрын
mine doesnt work for some reason it just says GetWaypoint is not a valid member of Path "Instance"
@mathiazscp
@mathiazscp 2 жыл бұрын
Hey, I know this might be a dumb question, but does it have to be R6 or R15?
@TomBuilds
@TomBuilds 2 жыл бұрын
I used R15. I haven’t tested with R6 so not sure. 👍
@mathiazscp
@mathiazscp 2 жыл бұрын
@@TomBuilds Thank you for answering!
@rileylecaptain113
@rileylecaptain113 2 жыл бұрын
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
@jaydenbaker6311 Жыл бұрын
How do you make them go by sight
@Oli33-j5j
@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
@Oli33-j5j Жыл бұрын
ill sub?
@Michalien112
@Michalien112 Жыл бұрын
How to make him jump, and how to make him detect people above him?
@MsSanjum
@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
@TomBuilds Жыл бұрын
I do say it in more recent videos. 👍
@9RBLX
@9RBLX 2 жыл бұрын
Does the script work for an R6 rig
@Blue-Coding
@Blue-Coding Жыл бұрын
Thanks!
@CalypsoLemonade1
@CalypsoLemonade1 2 жыл бұрын
It doesnt move but when i touch it it kills me, how do i fix this?
@Forgottenace9
@Forgottenace9 2 жыл бұрын
unanchor
@rileylecaptain113
@rileylecaptain113 2 жыл бұрын
thats the thing when it doesn't detect the player it wouldn't move
@Vincent-dn8zj
@Vincent-dn8zj 2 жыл бұрын
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-dn8zj
@Vincent-dn8zj 2 жыл бұрын
@@NotLuhvash sadly it still happens
@ascendedreality8546
@ascendedreality8546 2 жыл бұрын
@@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.
@Areyouseriousrnbro
@Areyouseriousrnbro 2 жыл бұрын
@@Vincent-dn8zj Maybe check the agentheight and agentradius and add 1 or more.
@sussus5841
@sussus5841 2 жыл бұрын
its the same for me but my npc wont ever move
@quackers519
@quackers519 2 жыл бұрын
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.
@ninjadj4826
@ninjadj4826 2 жыл бұрын
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
@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
@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
@TomBuilds Жыл бұрын
If you check out some of my newer AI videos, there should be something there. 👍
@selfwastaken
@selfwastaken 2 жыл бұрын
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
@Rowinu
@Rowinu 2 жыл бұрын
ty
@CemBarlin_YT
@CemBarlin_YT Жыл бұрын
Thaaaaaaaaaaaaaanks
@rhyswerner1748
@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!
@porta1master096
@porta1master096 2 жыл бұрын
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
@TomBuilds
@TomBuilds 2 жыл бұрын
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
@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
@TomBuilds Жыл бұрын
I doubt that will happen. At least, I hope it won’t 😂😂
@error9424
@error9424 Жыл бұрын
Wait a minute, why it when the code says if reached next
@p0gg_man965
@p0gg_man965 7 ай бұрын
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
@beedown
@beedown 6 ай бұрын
thx man
@FootySubject
@FootySubject Жыл бұрын
What if we choose to swim?
@tekoolll
@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
@zaxhir Жыл бұрын
use a ramp and make it transparent
@basicallyGuestcorn
@basicallyGuestcorn Жыл бұрын
It works, but when I was on a high place with a stair, it gives up
@AhkrisAF
@AhkrisAF Жыл бұрын
Now that I understand Lua script, I can do what I want
@Cojo_Catarou
@Cojo_Catarou 2 жыл бұрын
Me making this entire script and messing up one word by not capitalizing it
@TomBuilds
@TomBuilds 2 жыл бұрын
I’ve done the same. 😂
@CubeHeddiX
@CubeHeddiX 4 ай бұрын
Also custom animations.
@crystalwyrm4767
@crystalwyrm4767 Жыл бұрын
what would I do if I wanted it to be like a tower defense game?
@xyz0138
@xyz0138 Жыл бұрын
For some reason, it works fine but after like 10 seconds it stops
@RuiraMEOW
@RuiraMEOW 2 жыл бұрын
I'm sorry for this question but why my monster becomes invisible? Well it attacks, but it's invisible, what do I do?
@TomBuilds
@TomBuilds 2 жыл бұрын
Make sure you set all of the body parts' transparency to 0. Other than that, I'm not sure. :D
@RuiraMEOW
@RuiraMEOW 2 жыл бұрын
@@TomBuilds Okay, ty for answering!
@Mr.ChickenOfficialYT
@Mr.ChickenOfficialYT Жыл бұрын
How do I make it so that it just walks around aimlessly when a player is not in range
@TomBuilds
@TomBuilds Жыл бұрын
Check one of my latest pathfinding videos. Should be there. 👍
@Mr.ChickenOfficialYT
@Mr.ChickenOfficialYT Жыл бұрын
@@TomBuilds Ok thanks
@z_tock
@z_tock 2 жыл бұрын
None of these videos work for me and yet again it didnt work didnt even print my name in output
@mjak537
@mjak537 Жыл бұрын
I did everything in the video and It doesn't seem to be working.
@MegaVranjanac
@MegaVranjanac 2 жыл бұрын
My npc doesnt rotate at path any suggestions?
@rileylecaptain113
@rileylecaptain113 2 жыл бұрын
how do you make it so when it dosn't know where a player is it would randomly wander
@TomBuilds
@TomBuilds 2 жыл бұрын
I have an updated video on this. Check my channel for a similar video. 👍
@rileylecaptain113
@rileylecaptain113 2 жыл бұрын
@@TomBuilds thanks you
@djole_grobar
@djole_grobar 2 жыл бұрын
i wasted 2 hours typing the code and doesnt work. idk if i typed a line of code wrong. im not sure
@TomBuilds
@TomBuilds 2 жыл бұрын
Make sure to check for spelling mistakes and unnecessary capitulation, or necessary capitulation. 👍
@anime5954
@anime5954 Жыл бұрын
It worked the first time but then i cut the script accidently and now it won't work.
@dianamazzei8316
@dianamazzei8316 2 жыл бұрын
my rig is just floating why?
@RodsterInk
@RodsterInk 2 жыл бұрын
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.
@happy-day_30002. Жыл бұрын
it doesn't work for me i think its outdated or something
@callmeghst6542
@callmeghst6542 2 жыл бұрын
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
@TomBuilds
@TomBuilds 2 жыл бұрын
You could put a “wait(2)” in front of where it attacks you. 👍
@callmeghst6542
@callmeghst6542 2 жыл бұрын
@@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
@TomBuilds
@TomBuilds 2 жыл бұрын
If you want them to jump, just set the “AgentCanJump” to “true”. 👍
@Areyouseriousrnbro
@Areyouseriousrnbro 2 жыл бұрын
@@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
@pelsckopolesko Жыл бұрын
Can you make it so when he can’t see you, he will stop chasing you?
@TomBuilds
@TomBuilds Жыл бұрын
Check one of my newest AI videos. 👍
@CadeRankin2006
@CadeRankin2006 11 ай бұрын
My dude gets stuck when he is chasing the player
@LeumasMainChannel
@LeumasMainChannel Жыл бұрын
ITS not working
@ZordyGG
@ZordyGG Жыл бұрын
i don’t have the build rig
Происхождение ВСЕХ ЗВУКОВ в Roblox
16:37
Колпак
Рет қаралды 21 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
I got nothing sadly
5:10
Joshyboi_YT
Рет қаралды 17
Shortest To Longest ATTACKS in The Strongest Battlegrounds
13:42
I Spent 2,000 Hours Using Scratch
13:59
ggenije
Рет қаралды 658 М.
How To Make A CLICKER SIMULATOR - Roblox Studio (Part 3)
7:02
Creating A Roblox Horror Game In 1 Week! | Devlog #1
9:01
FedoraDEV
Рет қаралды 141 М.
Can I 100% Superliminal and Get a Refund?
23:36
Gronf
Рет қаралды 325 М.
I Made a ROBLOX Game With 1 LINE of Code!
4:13
RoDev
Рет қаралды 193 М.
Making a Genuinely Scary Roblox Horror Game
5:56
Hutcle
Рет қаралды 53 М.