Advertisement
1m1m0

Erik.ai Panic Mode

Jan 1st, 2024
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | Source Code | 0 0
  1. -- Erik's Panic Mode v1.0.0 --
  2.  
  3. local PanicDuration = math.random(10, 20) -- Duration of panic in seconds
  4. local MinJumpInterval = math.random(0.01, 0.1) -- Minimum time interval for jumping actions
  5. local MaxJumpInterval = math.random(0.25, 0.5) -- Maximum time interval for jumping actions
  6. local MinMoveInterval = 0.1 -- Minimum time interval for random movements
  7. local MaxMoveInterval = 2.0 -- Maximum time interval for random movements
  8. local ForgiveDuration = 10 -- Duration of wandering after panic is over
  9.  
  10. local NPC = script.Parent
  11. local FollowScript = NPC:WaitForChild("FollowScript")
  12. local WanderScript = NPC:WaitForChild("WanderScript")
  13. local Humanoid = NPC:WaitForChild("Humanoid")
  14.  
  15. local isPanic = false
  16. local lastHealth = Humanoid.Health
  17.  
  18. local function DisableFollowScript()
  19.     FollowScript.Disabled = true
  20. end
  21.  
  22. local function EnableFollowScript()
  23.     FollowScript.Disabled = false
  24. end
  25.  
  26. local function EnableWanderScript()
  27.     WanderScript.Disabled = false
  28. end
  29.  
  30. local function EnableScripts()
  31.     EnableFollowScript()
  32.     EnableWanderScript()
  33. end
  34.  
  35. local function PanicActions()
  36.     while isPanic do
  37.         -- Jump at random intervals
  38.         local jumpInterval = math.random(MinJumpInterval, MaxJumpInterval)
  39.         Humanoid.Jump = true
  40.         wait(jumpInterval)
  41.         Humanoid.Jump = false
  42.  
  43.         -- Simulate random panicking movements
  44.         local randomDirection = Vector3.new(math.random() - 0.5, 0, math.random() - 0.5).Unit
  45.         Humanoid:Move(randomDirection * 10) -- Move in a random direction
  46.  
  47.         -- Wait at random intervals
  48.         local moveInterval = math.random(MinMoveInterval, MaxMoveInterval)
  49.         local endTime = tick() + moveInterval
  50.         while tick() < endTime and isPanic do
  51.             wait(0.1)
  52.         end
  53.         Humanoid:Move(Vector3.new()) -- Stop moving
  54.     end
  55. end
  56.  
  57. local function Forgive()
  58.     -- Disable follow script during forgiveness
  59.     DisableFollowScript()
  60.  
  61.     -- Wait for forgiveness duration
  62.     wait(ForgiveDuration)
  63.  
  64.     -- Enable wander script and resume following after forgiveness
  65.     EnableWanderScript()
  66.     EnableFollowScript()
  67. end
  68.  
  69. Humanoid.HealthChanged:Connect(function()
  70.     if Humanoid.Health < lastHealth then
  71.         if not isPanic then
  72.             isPanic = true
  73.             Humanoid:Move(Vector3.new()) -- Stop moving
  74.  
  75.             -- Disable follow script
  76.             DisableFollowScript()
  77.  
  78.             -- Start panicking actions in a coroutine
  79.             coroutine.wrap(PanicActions)()
  80.  
  81.             wait(PanicDuration)
  82.             isPanic = false
  83.  
  84.             -- Start forgiveness process
  85.             coroutine.wrap(Forgive)()
  86.         end
  87.     end
  88.     lastHealth = Humanoid.Health
  89. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement