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
print(raycast.Instance)
end
end
end
wait()
end