Finally a video not 4 years old 🙏😭 The script works well but my attack animation does not stop it continues without switching to the walk animation I would like to know how to fix it even tho it's not a big deal I can just do a jumpsare scene instead
@@rustysillybandcan you help me please in my studio output it says: Workspace.rig.PathFindingScript:87: invalid argument #2 to ‘random’ (interval is empty)
THE ONLY WORKING PATHFINDING I FOUND AND IT WAS EXPLAINED AMAZINGLY THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU (If you couldn't tell I'm quite thankfull for this)
Great tutorial! you are one of those devs that actually explain things unlike the scam devs that make you script for like 500 hours and then nothing works; New subscriber great channel. Like personally I'm a small roblox dev but these tutorials are very good.
The problem with this model I don't like Is that I like my horror game to have multiple monsters But when i saw Local function(Ondeath) My dreams we're crushed.
This helped me a LOT The monster chases the player perfectly! But for some reason ( idk why) it can't follow the waypoints.. It doesn't even do the first one. But overall, It's perfect! I'm going to find how to make the pathfinding work.
Script if you're too lazy to type it (not organized like in the vid): local Players = game:GetService("Players") local PathfindingService = game:GetService("PathfindingService") local rig = script.Parent local function checkForCharacter(character) local rayOrigin = rig:FindFirstChild("HumanoidRootPart").Position local rayDirection = (character.HumanoidRootPart.Position - rayOrigin).Unit * 40 local raycastResult = workspace:Raycast(rayOrigin, rayDirection, RaycastParams.new()) if raycastResult then local raycastInstance = raycastResult.Instance if raycastInstance:IsDescendantOf(character) then return true end else return false end end local function findNearestPlayer() local players = Players:GetPlayers() local nearestPlayer = nil local maxDistance = 40 for _, player in pairs(players) do if player.Character = nil then local targetCharacter = player.Character local distance = (rig.HumanoidRootPart.Position - targetCharacter.HumanoidRootPart.Position).Magnitude if distance < maxDistance and checkForCharacter(targetCharacter) then nearestPlayer = targetCharacter maxDistance = distance end end end return nearestPlayer end local function attack(character) local distance = (rig.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude if distance > 5 then rig.Humanoid:MoveTo(character.HumanoidRootPart.Position) else character.Humanoid.Health = 0 end end local function calculatePath(destination) local agentParams = { ["AgentHeight"] = 5.5 ["AgentRadius"] = 4, ["AgentCanJump"] - false } local path - PathfindingService:CreatePath(agentParams) path:ComputeAsync(rig.HumanoidRootPart.Position, destination) return path end local function walkToDestination(destination) local path - calculatePath(destination) if path.Status == Enum.PathStatus.Success then for _, waypoint in pairs(path:GetWayPoints()) do local nearestPlayer = findNearestPlayer() if nearestPlayer then attack(nearestPlayer) break else rig.Humanoid.MoveTo(waypoint.Position) rig.Humanoid.MoveToFinished:Wait() end end else rig.Humanoid:MoveTo(destination - (rig.HumanoidRootPart.CFrame.LookVector * 10)) end end local function patrol() local waypoints = workspace.Waypoints:GetChildren() local randomNumber = math.random(1, #waypoints) walkToDestination(waypoints[randomNumber].Position) end while task.wait(0.3) do patrol() end
From the BOTTOM of my heart, I LOVE YOU. I have searched for tutorials for a WHILE and none of them worked, but this worked. You don't know how much I genuienly love you bro. Really helpful that you explained this since I have a little bit of coding experience and therefore I made changes that suited my game, thanks for that too
Thank you for your encouraging words! They mean a lot to me. I appreciate you taking the time to write this message and I hope the best for you in all future endeavors. Thanks again, have an amazing day!
If there is anyone who is making a single-player horror game (like me) and already has the jump scared added (it's one of his other videos) And is rather annoyed about the walking animation needing to be shorter, or your NPC having a reaction of a brick. There is a simple solution, make a separate script, put a folder into the script and name it "Animations", put an Animation in the folder and name the animation "Walk", and put your ID into the animation. Put the following into the script; " local rig = script.Parent local animations = script.Animations local walkAnimation = rig.Humanoid.Animator:LoadAnimation(animations.Walk) walkAnimation:Play()" The jumpscare will still play as normally, your NPC walking animation can be longer than the patrol and won't break, you can have an attack animation but the player won't see it (most likely)
Is there a way for you to make the monster switch animations? In the game im making I want the monster to start running when it locks on to you but theres no way to stop the other animation.
hey man! so i do have a few problems 1. even if the AI is faster then you, it will stop in little tiny intervals, causing it to not kill you even if you cant outrun it via walkspeed difference 2. i have barriers placed around the map, and if i am on the other side of the barrier the AI is, it will just walk to some other waypoint instead of continuing to chase me/going around the wall, i think this is generally because of how raycasting works
Thanks alot man I am making a game but the monster you made for thr kit was not to my liking so I took the script from this one and put it into my Monster so its extra scary so yeah preciate it man
Hi there! This series is simply covering every popular horror game mechanic so that you can create any horror game you would like. A few mechanics include: - Flashlight - Monsters - Jump scares - Objectives - Story - etc.. Thank you for watching, have an amazing day!
I'm having a slight issue, the monster is not chasing the player, is it because I have a custom player model for the game? It could also be because my monster is large, idk Edit: found the issue, the problem is that I can't fix it, the reason why it isnt working is because its root part is higher than the player meaning it doesn't see the player, my problem is that I can't make my monsters legs smaller, is there any other fix?
You can try to increase the distance that it is able to attack from. Instead of doing 5, you can do 10. Other than that, you can move the RootPart down closer to his legs, but you will also have to edit the HipHeight in the Humanoid. Thanks for watching, have an amazing day!
@@rustysillybandI resulted in using a different model (just an r6 block model) and the game the monster is for is like a backrooms type game, the problem is that it refuses to walk if placed on a part or if the way points are behind a wall (it's able to go around the wall it just won't)
Thank you so much for this tutorial, it really helps for my horror game. Do you have another tutorial that can help add a jump scare if the player is touched by the rig? thank you
can you please make another video about fixing the bug on your model? When the waypoints are behind a wall he just hugs the wall instead of going around it...
Heyy Rusty! Its me again. I was working on my horror game with very little knowledge and I ran into an issue. I was wondering how to adjust the FirstPerson Script you made in your other video to make it where when GUI is visible it is unlocked, so that you can move your mouse around. Please let me know how to fix this!!
Hi there! You can simply create a screenGui with a textButton inside of it. After that, simply set the size of the textButton to (0,0,0,0) and tick the Modal property to true. This will allow you to move your mouse around in first person. Thanks for watching, have an amazing day!
thank you bro so much i just got your pack and ive been trying SO MUCH videos ignore the people who told you that it does not work at all they didnt follow ur steps! ur amazing dude..
Great vid! Im currentlt working on a smart AI which will chase the player until it can't see them anymore. If it can't see the player, it will continue in the direction the player went to try and gaun sight of them again. I'm having a lot of issue with the code but It's almost done I can feel it
( i learning english, so sorry anything 😅) I've been looking at pathfinding for a long time and every script I went through I found an error in the output: Stack Begin - Studio 21:57:26.952 Script 'Workspace.HorrorMonster.PathfindingScript', Line 108 - function patrol - Studio - PathfindingScript:108 21:57:26.953 Script 'Workspace.HorrorMonster.PathfindingScript', Line 117 - Studio - PathfindingScript:117 21:57:26.953 Stack End - Studio Do you know how I can solve this?
Can you please make a tutorial that’s pretty much opposite to this? One about a little creature that runs around randomly, and when a player gets close it runs away unless the player is crouched? Then if the player is crouched they can sneak up to it and pet it
i did everything in the script but the npc doesn't follow the player, just goes to waypoints i tried using your model and that doesn't follow the player either
thanks for the tutorial, this was actually my first long script that actually worked, just one thing, my monster commonly gets stuck on walls after a couple of patrols, as he picks a waypoint on the other side of the map, is there a way to fix that?
Wait… what if I just tied a part from the waypoints to the player, make it invisible so there isn’t just a cube on top of the player, tie a part to the monster that does damage, and just make the monster go for the waypoint? (Btw I haven’t tried using this yet but I will next week so im not saying that it doesn’t work.)
For some reason the monster in my game just slides across the map and it doesn't go towards any of the waypoints and it doesn't chase or kill the player
Please bro I really want to make a horror game and I have been stuck on this for about 2 weeks and I can't code and I keep mixing up all of the code please it would mean the world to me