This has taught me a lot, and it's so helpful you actually talked through the script, not just telling us to paste it from the description (and thank you for still putting it in description, I got to paste it in and learn from where I didn't understand, saving time.). Thank you!
I did this instead of the raycast and it works local touchConnection touchConnection = plrHitbox.Touched:Connect(function(partHit) for _, guardChild in pairs(guard:GetChildren()) do if partHit == guardChild and guardChild:IsA("MeshPart") and canTouch and targetReached == false then canTouch = false task.cancel(thread) targetReached = true print("Player hit by Guard") char.Humanoid.Health = 0 touchConnection:Disconnect() end end end)
Teletacos, if I could give you a million dollars, I would, because you just saved me so much frustration with the pathfinding lag glitch. I had no idea SetNetworkOwner was a thing. Thank you so much!
This Video actually helped me so much, i can work on my horror game in actual horror so that, the monster can actually go past you when your in a closet. ("Creepy: Rebirth" is what it's called the third version of my previous two one from 2020 and one "Creepy: Reborn" and for this new installment it's advanced now, you can probably do things that isn't usually in horror games like peeking left and right or just the lore in General. Probably)
Its good, but when it goes to certain points, it stops after going to them. It only goes to 2 waypoints and none of the others. after doing this for a few times it stops and doesnt do anything but play the animation
i think you need to change the number he mentions in the video on the 'local randomNum = math.random(1, #waypoints)' row, you might need to change the 1
@@aikious7638 i think you need to change the number he mentions in the video on the 'local randomNum = math.random(1, #waypoints)' row, you might need to change the 1
@@Darklordhedgehogmath.random gets something between number1 and number2, so 1 wouldn’t be changed, #waypoints would be changed to allow a higher random number. So if #waypoints was 5, it would get a random number from 1 to 5, if it were 8, 1 to 8.
Click on element and do square, put couple of squares and select them all, left click, select file. Then name the file waypoints and be sure they anchored and have cancollide off so the bot wont be stuck
The script still works as of this video with only one minor change: 4:54 line 18 is now rayParam.FilterType = Enum.RaycastFilterType.Exclude This is due to a Roblox term change from Blacklist -> Exclude & Whitelist -> Include (prob due to political reasons... but everything remains the same otherwise)
Not bad, however when I enter any maze/building and it hits a wall it instantly breaks without any error/print/warning message. Any way to fix this annoying issue?
i got it to work but the only animation that works is the one in the video :/ (3 ‘edits’ down below 👇) edit: i have spent 5 hours of my entire life just trying to get the walk animation to change to actually dang walking and its no working CAN YOU PLEASE TELL ME A FIX IM GOING INSANE Edit 2: I found a half-fix Edit 3: I fixed it 2 days after the problem happened by making my own animation 👍
if you check the output, it will probably say "Failed to load animation - sanitized ID: [ID] this is because in order for the animation to load, you need to own it. So sadly in order to get the animation to work, you need to make it yourself.
@@realestfr funnily enough, I did that the day after, after searching up an animation tutorial to make my own crouching animation, and then made my own walk and attack soon after, thanks for trying to help, though!
This is really cool but idk why it doesnt work. Maybei missed a bit, but i cant fix it. The code just doesnt work at all, the NPC just sits there. Sad :(
the script at the intro of this vid would literally crash your game this is telling me that if i watch your tutorials my brain will deep fry, crash and i will go into a 15 year coma and wake up for 2 days before dying
I've noticed that whenever I get into the game I'm testing, the animations don't work, and on top of that whenever the entity tries running over to me and dealing damage, it doesn't deal any damage and it stops him in his place, preventing him from going back to the waypoints. Do you have a fix for this? found a fix, get an R15 dummy from the toolbox, make sure the waypoints are inside of workspace, and not still in the part it came in, and make sure the attack sound is actually a child of the humanoids head. Hope this helps
Everything's in order but i have a few issues. 1. The monster sometimes freezes for a spit second before attacking again 2. I added a script that spawns a dead body in place of the player who died, this ends up crashing the monster and it doesnt move or anything anymore 3. Sometimes the animations fully bug out This is otherwise a great tutorial!
Line 18 of the code is outdated, I'm pretty sure you can replace it with this and it should still work: rayParams.FilterType = Enum.RaycastFilterType.Ignore
Its a replica of Gnome Code's Teddy bear script. Anyone think this doesn't work can try using this link directed to the original video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-gSYx6MVa9Tc.html
a system message that says something is showing up. The message is: Network Ownership API cannot be called on Anchored parts or parts welded to Anchored parts.
Hello, i am having a problem that the animations are not working because in my code, in any moment animPlaying is set to true, is there a way to fix it?
Help!!! My animation plays exactly after 5 seconds the player died and the camera changed position, how can I delete this waiting time or make it shorter? I checked the animation and it's starting on the "0" second bar. My script: --{{Services}}-- local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") --{{Variables}}-- local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local currentCamera = game.Workspace.CurrentCamera local rig = game.Workspace.JumpscareBox.GranpaModel local sound = game.Workspace.JumpscareBox.JumpscareSound2 --{{Functions}}-- local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play() local function onDeath() currentCamera.CameraType = Enum.CameraType.Scriptable currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3) currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 0, 0))+(rig.Head.CFrame.LookVector * 3)), rig.Head.Position) local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5}) tween:Play() task.wait(5) currentCamera.CameraType = Enum.CameraType.Custom end character.Humanoid.Died:Connect(onDeath)
It wont let me change the animation for walking. Also it stops in place for about 5 seconds a lot weather it's chasing you or just walking around Other than these it's pretty good
@@TeletacosRobloxTutorials I also have a problem where he just goes to me then just stops? I have no idea why, I eddited the script and then changed it back to no avail.
Hey man, great tutorial. I know you posted this a long time ago but i just have an issue. Even though I set the AI to be faster than the player, it seems to slow down around 2-3 studs from the player. I believe this has to do with the attack script since it is based off distance, but i’d like to know if you had a solution. Thanks!
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
Hello! Please reply to this comment, the script works however is there a way to change the enemy’s walkspeed or something similar? Thank you and hope you reply!
for some reason the walking animation doesn't play, the attack animation works and all but not the walking anim. Can someone Please leave a reply explaining this bug
What i did was change the walking animation to be looped in the place where you make it and coded it to stop for attack animaiton to to come then play to play it again.
@@vestigefish I think i understand why it didn't work, cua on the script they said like tehy need 2 animations, and you dont have the anims qo the qcript says it doesnt exist what do i do and it mess all of your game
local PathfindingService = game:GetService("PathfindingService") local npc = script.Parent local humanoid = npc:WaitForChild("Humanoid") local hrp = npc:WaitForChild("HumanoidRootPart") hrp:SetNetworkOwner(nil) local walkAnim = humanoid.Animator:LoadAnimation(script.Walk) local attackAnim = humanoid.Animator:LoadAnimation(script.Attack) local pathParams = { AgentHeight = 5, AgentRadius = 3, AgentCanJump = true, } local rayParams = RaycastParams.new() rayParams.FilterType = Enum.RaycastFilterType.Blacklist rayParams.FilterDescendantsInstances = {npc} local lastPos local animPlaying = false local RANGE = 60 local DAMAGE = 30 local function canSeeTarget(target) local orgin = hrp.Position local direction = (target.HumanoidRootPart.Position - hrp.Position).Unit * RANGE local ray = workspace:Raycast(orgin, direction, rayParams) if ray and ray.Instance then if ray.Instance:IsDescendantOf(target) then return true else return false end else return false end end local function findTarget() local players = game.Players:GetPlayers() local maxDistance = RANGE local nearestTarget for i, player in pairs(players) do if player.Character then local target = player.Character local distance = (hrp.Position - target.HumanoidRootPart.Position).Magnitude if distance < maxDistance and canSeeTarget(target) then nearestTarget = target maxDistance = distance end end end return nearestTarget end local function getPath(destination) local path = PathfindingService:CreatePath(pathParams) path:ComputeAsync(hrp.Position, destination.Position) return path end local function attack(target) local distance = (hrp.Position - target.HumanoidRootPart.Position).Magnitude local debounce = false if distance > 5 then humanoid:MoveTo(target.HumanoidRootPart.Position) else if debounce == false then debounce = true npc.Head.AttackSound:Play() attackAnim:Play() target.Humanoid.Health -= DAMAGE task.wait(0.5) debounce = false end end end local function walkTo(destination) local path = getPath(destination) if path.Status == Enum.PathStatus.Success then for i, waypoint in pairs(path:GetWaypoints()) do path.Blocked:Connect(function() path:Destroy() end) if animPlaying == false then walkAnim:Play() animPlaying = true end attackAnim:Stop() local target = findTarget() if target and target.Humanoid.Health > 0 then lastPos = target.HumanoidRootPart.Position attack(target) break else if waypoint.Action == Enum.PathWaypointAction.Jump then humanoid:ChangeState(Enum.HumanoidStateType.Jumping) end if lastPos then humanoid:MoveTo(lastPos) humanoid.MoveToFinished:Wait() lastPos = nil break else humanoid:MoveTo(waypoint.Position) humanoid.MoveToFinished:Wait() end end end else return end end local function patrol() local waypoints = workspace.Waypoints:GetChildren() local randomNum = math.random(1, #waypoints) walkTo(waypoints[randomNum]) end while task.wait(0.2) do patrol() end change the script with this