Advertisement
munciseek

Untitled

Dec 1st, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.74 KB | None | 0 0
  1. -- Services
  2.  
  3. local Players = game:GetService("Players")
  4. local ReSt = game:GetService("ReplicatedStorage")
  5. local RS = game:GetService("RunService")
  6. local TS = game:GetService("TweenService")
  7. local CG = game:GetService("CoreGui")
  8.  
  9. -- Variables
  10.  
  11. local Plr = Players.LocalPlayer
  12. local Char = Plr.Character or Plr.CharacterAdded:Wait()
  13. local Hum = Char:WaitForChild("Humanoid")
  14. local Camera = workspace.CurrentCamera
  15.  
  16. local StaticRushSpeed = 60
  17.  
  18. local FindPartOnRayWithIgnoreList = workspace.FindPartOnRayWithIgnoreList
  19. local WorldToViewportPoint = Camera.WorldToViewportPoint
  20.  
  21. local SelfModules = {
  22. DefaultConfig = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Doors%20Entity%20Spawner/DefaultConfig.lua"))(),
  23. Functions = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Functions.lua"))(),
  24. }
  25. local ModuleScripts = {
  26. ModuleEvents = require(ReSt.ClientModules.Module_Events),
  27. MainGame = require(Plr.PlayerGui.MainUI.Initiator.Main_Game),
  28. }
  29. local EntityConnections = {}
  30.  
  31. local Spawner = {}
  32.  
  33. -- Misc Functions
  34.  
  35. function getPlayerRoot()
  36. return Char:FindFirstChild("HumanoidRootPart") or Char:FindFirstChild("Head")
  37. end
  38.  
  39. function dragEntity(entityModel, pos, speed)
  40. local entityConnections = EntityConnections[entityModel]
  41.  
  42. if entityConnections.movementNode then
  43. entityConnections.movementNode:Disconnect()
  44. end
  45.  
  46. entityConnections.movementNode = RS.Stepped:Connect(function(_, step)
  47. if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
  48. local rootPos = entityModel.PrimaryPart.Position
  49. local diff = Vector3.new(pos.X, pos.Y, pos.Z) - rootPos
  50.  
  51. if diff.Magnitude > 0.1 then
  52. entityModel:SetPrimaryPartCFrame(CFrame.new(rootPos + diff.Unit * math.min(step * speed, diff.Magnitude)))
  53. else
  54. entityConnections.movementNode:Disconnect()
  55. end
  56. end
  57. end)
  58.  
  59. repeat task.wait() until not entityConnections.movementNode.Connected
  60. end
  61.  
  62. function loadSound(soundData)
  63. local sound = Instance.new("Sound")
  64. local soundId = tostring(soundData[1])
  65. local properties = soundData[2]
  66.  
  67. for i, v in next, properties do
  68. if i ~= "SoundId" and i ~= "Parent" then
  69. sound[i] = v
  70. end
  71. end
  72.  
  73. if soundId:find("rbxasset://") then -- Custom audio
  74. sound.SoundId = soundId
  75. else
  76. local numberId = soundId:gsub("%D", "")
  77.  
  78. sound.SoundId = "rbxassetid://".. numberId
  79. end
  80.  
  81. sound.Parent = workspace
  82.  
  83. return sound
  84. end
  85.  
  86. -- Functions
  87.  
  88. Spawner.createEntity = function(config)
  89. for i, v in next, SelfModules.DefaultConfig do
  90. if config[i] == nil then
  91. config[i] = v
  92. end
  93. end
  94.  
  95. config.Speed = StaticRushSpeed / 100 * config.Speed
  96.  
  97. -- Model
  98.  
  99. local entityModel = LoadCustomInstance(config.Model)
  100.  
  101. if typeof(entityModel) == "Instance" and entityModel.ClassName == "Model" then
  102. entityModel.PrimaryPart = entityModel.PrimaryPart or entityModel:FindFirstChildWhichIsA("BasePart")
  103.  
  104. if entityModel.PrimaryPart then
  105. entityModel.PrimaryPart.Anchored = true
  106.  
  107. if config.CustomName then
  108. entityModel.Name = config.CustomName
  109. end
  110.  
  111. entityModel:SetAttribute("IsCustomEntity", true)
  112. entityModel:SetAttribute("NoAI", false)
  113.  
  114. -- EntityTable
  115.  
  116. local entityTable = {
  117. Model = entityModel,
  118. Config = config,
  119. Debug = {
  120. OnEntitySpawned = function() end,
  121. OnEntityDespawned = function() end,
  122. OnEntityStartMoving = function() end,
  123. OnEntityFinishedRebound = function() end,
  124. OnEntityEnteredRoom = function() end,
  125. OnLookAtEntity = function() end,
  126. OnDeath = function() end
  127. }
  128. }
  129.  
  130. return entityTable
  131. end
  132. end
  133. end
  134.  
  135. Spawner.runEntity = function(entityTable)
  136. -- Nodes
  137.  
  138. local entityNodes = {}
  139.  
  140. for _, room in next, workspace.CurrentRooms:GetChildren() do
  141. local nodes = room:WaitForChild("Nodes", 1)
  142.  
  143. if nodes then
  144. nodes = nodes:GetChildren()
  145.  
  146. table.sort(nodes, function(a, b)
  147. return a.Name < b.Name
  148. end)
  149.  
  150. for _, node in next, nodes do
  151. entityNodes[#entityNodes + 1] = node
  152. end
  153. end
  154. end
  155.  
  156. -- Spawn
  157.  
  158. local entityModel = entityTable.Model:Clone()
  159. local startNodeIndex = entityTable.Config.BackwardsMovement and #entityNodes or 1
  160. local startNodeOffset = entityTable.Config.BackwardsMovement and -50 or 50
  161.  
  162. EntityConnections[entityModel] = {}
  163. local entityConnections = EntityConnections[entityModel]
  164.  
  165. entityModel:SetPrimaryPartCFrame(entityNodes[startNodeIndex].CFrame * CFrame.new(0, 0, startNodeOffset) + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0))
  166. entityModel.Parent = workspace
  167. task.spawn(entityTable.Debug.OnEntitySpawned)
  168.  
  169. -- Mute entity on spawn
  170.  
  171. if CG:FindFirstChild("JumpscareGui") or (Plr.PlayerGui.MainUI.Death.HelpfulDialogue.Visible and not Plr.PlayerGui.MainUI.DeathPanelDead.Visible) then
  172. warn("on death screen, mute entity")
  173.  
  174. for _, v in next, entityModel:GetDescendants() do
  175. if v.ClassName == "Sound" and v.Playing then
  176. v:Stop()
  177. end
  178. end
  179. end
  180.  
  181. -- Flickering
  182.  
  183. if entityTable.Config.FlickerLights[1] then
  184. firesignal(game.ReplicatedStorage.EntityInfo.UseEventModule.OnClientEvent, "flicker", ReSt.GameData.LatestRoom.Value, entityTable.Config.FlickerLights[2])
  185. end
  186.  
  187. -- Movement
  188.  
  189. task.wait(entityTable.Config.DelayTime)
  190.  
  191. local enteredRooms = {}
  192.  
  193. entityConnections.movementTick = RS.Stepped:Connect(function()
  194. if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
  195. local entityPos = entityModel.PrimaryPart.Position
  196. local rootPos = getPlayerRoot().Position
  197. local floorRay = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, Vector3.new(0, -10, 0)), {entityModel, Char})
  198. local playerInSight = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, rootPos - entityPos), {entityModel, Char}) == nil
  199.  
  200. -- Entered room
  201.  
  202. if floorRay ~= nil and floorRay.Name == "Floor" then
  203. for _, room in next, workspace.CurrentRooms:GetChildren() do
  204. if floorRay:IsDescendantOf(room) and not table.find(enteredRooms, room) then
  205. enteredRooms[#enteredRooms + 1] = room
  206. task.spawn(entityTable.Debug.OnEntityEnteredRoom, room)
  207.  
  208. -- Break lights
  209.  
  210. if entityTable.Config.BreakLights then
  211. firesignal(game.ReplicatedStorage.EntityInfo.UseEventModule.OnClientEvent, "shatter", room)
  212. end
  213.  
  214. break
  215. end
  216. end
  217. end
  218.  
  219. -- Camera shaking
  220.  
  221. local shakeConfig = entityTable.Config.CamShake
  222. local shakeMag = (getPlayerRoot().Position - entityModel.PrimaryPart.Position).Magnitude
  223.  
  224. if shakeConfig[1] and shakeMag <= shakeConfig[3] then
  225. local shakeRep = {}
  226.  
  227. for i, v in next, shakeConfig[2] do
  228. shakeRep[i] = v
  229. end
  230. shakeRep[1] = shakeConfig[2][1] / shakeConfig[3] * (shakeConfig[3] - shakeMag)
  231.  
  232. ModuleScripts.MainGame.camShaker.ShakeOnce(ModuleScripts.MainGame.camShaker, table.unpack(shakeRep))
  233. end
  234.  
  235. -- Player in sight
  236.  
  237. if playerInSight then
  238. if game.Players.LocalPlayer.Character:FindFirstChild("Crucifix") then
  239. local tsa = game:GetService("TweenService")
  240. entityModel:SetAttribute("NoAI", true)
  241. local cruxy = game.Players.LocalPlayer.Character.Crucifix.Handle:Clone()
  242. game.Players.LocalPlayer.Character.Crucifix:Destroy()
  243. cruxy.Parent = game.Workspace
  244. cruxy.Name = "cruxy"
  245. cruxy.Anchored = true
  246. cruxy.Color = Color3.fromRGB(255, 255, 0)
  247. cruxy.Material = Enum.Material.Neon
  248. local cruxeffect = tsa:Create(cruxy, TweenInfo.new(5), {Transparency = 1})
  249. cruxeffect:Play()
  250. game.Workspace.Smiley.SmileyNew.NoCollision = true
  251. wait(2)
  252. firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'You really thought u can use crucifix on me??',true,7)
  253. game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
  254. wait(3)
  255. firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'You underestimated me.',true,7)
  256. game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
  257. wait(2)
  258. firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'Die.',true,7)
  259. game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
  260. local movety = tsa:Create(game.Workspace.Smiley.SmileyNew, TweenInfo.new(2), {Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position})
  261. movety:Play()
  262. wait(2)
  263. local msg = {"You really tried that??", "Well... uh...", "If you meet him again just don't do it again."} -- PUT YOUR MESSAGE HERE, add commas with quotation marks for multiple of them, ex: {"msg1", "msg2"}
  264. local curious = true -- change this to true for it to be the curious guiding light
  265. local reason = "Smiley" -- Death cause, for ex: "Smiler" would say "You died to Smiler"
  266.  
  267. -- SCRIPT, DO NOT TOUCH
  268.  
  269. game.Players.LocalPlayer.Character.Humanoid.Health = 0
  270. if curious == true then
  271. firesignal(game:GetService("ReplicatedStorage").EntityInfo.DeathHint.OnClientEvent, msg,'Yellow')
  272. else
  273. firesignal(game:GetService("ReplicatedStorage").EntityInfo.DeathHint.OnClientEvent, msg,'Blue')
  274. end
  275. game.ReplicatedStorage.GameStats["Player_".. game.Players.LocalPlayer.Name].Total.DeathCause.Value = reason
  276. end
  277. game.Workspace.Smiley:Destroy()
  278. -- Look at entity
  279.  
  280. local _, onScreen = WorldToViewportPoint(Camera, entityModel.PrimaryPart.Position)
  281.  
  282. if onScreen then
  283. task.spawn(entityTable.Debug.OnLookAtEntity)
  284. end
  285.  
  286. -- Kill player
  287.  
  288. if entityTable.Config.CanKill and not Char:GetAttribute("IsDead") and not Char:GetAttribute("Invincible") and not Char:GetAttribute("Hiding") and (getPlayerRoot().Position - entityModel.PrimaryPart.Position).Magnitude <= entityTable.Config.KillRange then
  289. task.spawn(function()
  290. Char:SetAttribute("IsDead", true)
  291.  
  292. -- Mute entity
  293.  
  294. warn("mute entity")
  295.  
  296. for _, v in next, entityModel:GetDescendants() do
  297. if v.ClassName == "Sound" and v.Playing then
  298. v:Stop()
  299. end
  300. end
  301.  
  302. -- Jumpscare
  303.  
  304. if entityTable.Config.Jumpscare[1] then
  305. Spawner.runJumpscare(entityTable.Config.Jumpscare[2])
  306. end
  307.  
  308. -- Death handling
  309.  
  310. task.spawn(entityTable.Debug.OnDeath)
  311. Hum.Health = 0
  312. ReSt.GameStats["Player_".. Plr.Name].Total.DeathCause.Value = entityModel.Name
  313.  
  314. if #entityTable.Config.CustomDialog > 0 then
  315. print("Guiding light is currently broken. Message: " ..entityTable.Config.CustomDialog.. " didn't load.")
  316. end
  317.  
  318. -- Unmute entity
  319.  
  320. task.spawn(function()
  321. repeat task.wait() until Plr.PlayerGui.MainUI.DeathPanelDead.Visible
  322.  
  323. warn("unmute entity:", entityModel)
  324.  
  325. for _, v in next, entityModel:GetDescendants() do
  326. if v.ClassName == "Sound" then
  327. local oldVolume = v.Volume
  328.  
  329. v.Volume = 0
  330. v:Play()
  331. TS:Create(v, TweenInfo.new(2), {Volume = oldVolume}):Play()
  332. end
  333. end
  334. end)
  335. end)
  336. end
  337. end
  338. end
  339. end)
  340.  
  341. task.spawn(entityTable.Debug.OnEntityStartMoving)
  342.  
  343. -- Cycles
  344.  
  345. local cyclesConfig = entityTable.Config.Cycles
  346.  
  347. if entityTable.Config.BackwardsMovement then
  348. local inverseNodes = {}
  349.  
  350. for nodeIdx = #entityNodes, 1, -1 do
  351. inverseNodes[#inverseNodes + 1] = entityNodes[nodeIdx]
  352. end
  353.  
  354. entityNodes = inverseNodes
  355. end
  356.  
  357. for cycle = 1, math.max(math.random(cyclesConfig.Min, cyclesConfig.Max), 1) do
  358. for nodeIdx = 1, #entityNodes, 1 do
  359. dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
  360. end
  361.  
  362. if cyclesConfig.Max > 1 then
  363. for nodeIdx = #entityNodes, 1, -1 do
  364. dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
  365. end
  366. end
  367.  
  368. -- Rebound finished
  369.  
  370. task.spawn(entityTable.Debug.OnEntityFinishedRebound)
  371.  
  372. if cycle < cyclesConfig.Max then
  373. task.wait(cyclesConfig.WaitTime)
  374. end
  375. end
  376.  
  377. -- Destroy
  378.  
  379. if not entityModel:GetAttribute("NoAI") then
  380. for _, v in next, entityConnections do
  381. v:Disconnect()
  382. end
  383.  
  384. entityModel:Destroy()
  385. task.spawn(entityTable.Debug.OnEntityDespawned)
  386. end
  387. end
  388.  
  389. Spawner.runJumpscare = function(config)
  390. -- Variables
  391.  
  392. local image1 = LoadCustomAsset(config.Image1)
  393. local image2 = LoadCustomAsset(config.Image2)
  394. local sound1, sound2 = nil, nil
  395.  
  396. if config.Sound1 then
  397. sound1 = loadSound(config.Sound1)
  398. end
  399.  
  400. if config.Sound2 then
  401. sound2 = loadSound(config.Sound2)
  402. end
  403.  
  404. -- UI Construction
  405.  
  406. local JumpscareGui = Instance.new("ScreenGui")
  407. local Background = Instance.new("Frame")
  408. local Face = Instance.new("ImageLabel")
  409.  
  410. JumpscareGui.Name = "JumpscareGui"
  411. JumpscareGui.IgnoreGuiInset = true
  412. JumpscareGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  413.  
  414. Background.Name = "Background"
  415. Background.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  416. Background.BorderSizePixel = 0
  417. Background.Size = UDim2.new(1, 0, 1, 0)
  418. Background.ZIndex = 999
  419.  
  420. Face.Name = "Face"
  421. Face.AnchorPoint = Vector2.new(0.5, 0.5)
  422. Face.BackgroundTransparency = 1
  423. Face.Position = UDim2.new(0.5, 0, 0.5, 0)
  424. Face.ResampleMode = Enum.ResamplerMode.Pixelated
  425. Face.Size = UDim2.new(0, 150, 0, 150)
  426. Face.Image = image1
  427.  
  428. Face.Parent = Background
  429. Background.Parent = JumpscareGui
  430. JumpscareGui.Parent = CG
  431.  
  432. -- Tease
  433.  
  434. local teaseConfig = config.Tease
  435. local absHeight = JumpscareGui.AbsoluteSize.Y
  436. local minTeaseSize = absHeight / 5
  437. local maxTeaseSize = absHeight / 2.5
  438.  
  439. if teaseConfig[1] then
  440. local teaseAmount = math.random(teaseConfig.Min, teaseConfig.Max)
  441.  
  442. sound1:Play()
  443.  
  444. for _ = teaseConfig.Min, teaseAmount do
  445. task.wait(math.random(100, 200) / 100)
  446.  
  447. local growFactor = (maxTeaseSize - minTeaseSize) / teaseAmount
  448. Face.Size = UDim2.new(0, Face.AbsoluteSize.X + growFactor, 0, Face.AbsoluteSize.Y + growFactor)
  449. end
  450.  
  451. task.wait(math.random(100, 200) / 100)
  452. end
  453.  
  454. -- Flashing
  455.  
  456. if config.Flashing[1] then
  457. task.spawn(function()
  458. while JumpscareGui.Parent do
  459. Background.BackgroundColor3 = config.Flashing[2]
  460. task.wait(math.random(25, 100) / 1000)
  461. Background.BackgroundColor3 = Color3.new(0, 0, 0)
  462. task.wait(math.random(25, 100) / 1000)
  463. end
  464. end)
  465. end
  466.  
  467. -- Shaking
  468.  
  469. if config.Shake then
  470. task.spawn(function()
  471. local origin = Face.Position
  472.  
  473. while JumpscareGui.Parent do
  474. Face.Position = origin + UDim2.new(0, math.random(-10, 10), 0, math.random(-10, 10))
  475. Face.Rotation = math.random(-5, 5)
  476.  
  477. task.wait()
  478. end
  479. end)
  480. end
  481.  
  482. -- Jumpscare
  483.  
  484. Face.Image = image2
  485. Face.Size = UDim2.new(0, maxTeaseSize, 0, maxTeaseSize)
  486. sound2:Play()
  487.  
  488. TS:Create(Face, TweenInfo.new(0.75), {Size = UDim2.new(0, absHeight * 3, 0, absHeight * 3), ImageTransparency = 0.5}):Play()
  489. task.wait(0.75)
  490. JumpscareGui:Destroy()
  491.  
  492. if sound1 then
  493. sound1:Destroy()
  494. end
  495.  
  496. if sound2 then
  497. sound2:Destroy()
  498. end
  499. end
  500.  
  501. -- Scripts
  502.  
  503. task.spawn(function()
  504. while true do
  505. local inSession = false
  506.  
  507. for _, v in next, workspace:GetChildren() do
  508. if v.Name == "RushMoving" or v.Name == "AmbushMoving" or v:GetAttribute("IsCustomEntity") then
  509. inSession = true
  510. break
  511. end
  512. end
  513.  
  514. ReSt.GameData.ChaseInSession.Value = inSession
  515. task.wait(0.5)
  516. end
  517. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement