I made a guard movement system!

I used to play this game called “Payday 2” and in the game there was basically like these guards which would patrol an area. Well I decided to recreate that in roblox and this is what I got. I think I did pretty well, though if you guys got any ideas how I can improve on it please tell me. And just to clear the elephant out of the room I want them to move one after the other so the player has a chance to move around the map.

It has come to my attention that this can be useful for helping people make stealth games, here is the patrol system. PatrolSystem.rbxm (14.7 KB)


Wow. It looks fantastic, I haven’t seen many things like this. Of course, it could definitely look nicer? Perhaps make the avatars, “Guard” billboard gui, and the parts they move to more stylish to make the game more enjoyable for users. Other then that outstanding job!

Yea I just got finished with detection, I used trigonometry (specifically the law of cosines)

while true do
	for _, plr in pairs(game.Players:GetPlayers()) do
		local char = plr.Character or plr.CharacterAdded:Wait()
		local dif = (script.Parent.Head.Position - char.Head.Position)
		local lVector = script.Parent.Head.CFrame.LookVector
		local angle = math.deg(math.acos(dif.Unit:Dot(lVector)/ (dif.Unit.Magnitude * lVector.Magnitude)))
		if angle > 90 and angle < 180 and 25 > dif.Magnitude and not script.Parent.IsAlerted.Value then
			script.Parent.IsAlerted.Value = true
			local raycast = workspace:Raycast(script.Parent.Head.Position, dif.Unit * 25)
			if raycast then
1 Like

This is fantastic! I’ve seen pathfinding bots, this adds a new level. People could use this for so many things.

Would you guys want the code? If it would really help I would be willing to leave you guys a rbxl file of it

Currently I don’t need it, but I’m sure it could benefit many other games.

This is really useful since me and my freind are making an entry point spinoff.
But do you know how to give them animations?

You need to give them a animator instance then play that animation while its moving

1 Like

Now that i think of it thats quite simple :laughing:

Sorry to ask you another question but how do i open rbxm files since its not opening and apprently only rbxl file are supported?

u drag it into your studio like its a file its not a rbxl thing

So i open a game then drag it in?