Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local Players = game:GetService("Players")
- local ReSt = game:GetService("ReplicatedStorage")
- local RS = game:GetService("RunService")
- local TS = game:GetService("TweenService")
- local CG = game:GetService("CoreGui")
- -- Variables
- local Plr = Players.LocalPlayer
- local Char = Plr.Character or Plr.CharacterAdded:Wait()
- local Hum = Char:WaitForChild("Humanoid")
- local Camera = workspace.CurrentCamera
- local StaticRushSpeed = 60
- local FindPartOnRayWithIgnoreList = workspace.FindPartOnRayWithIgnoreList
- local WorldToViewportPoint = Camera.WorldToViewportPoint
- local SelfModules = {
- DefaultConfig = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Doors%20Entity%20Spawner/DefaultConfig.lua"))(),
- Functions = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Functions.lua"))(),
- }
- local ModuleScripts = {
- ModuleEvents = require(ReSt.ClientModules.Module_Events),
- MainGame = require(Plr.PlayerGui.MainUI.Initiator.Main_Game),
- }
- local EntityConnections = {}
- local Spawner = {}
- -- Misc Functions
- function getPlayerRoot()
- return Char:FindFirstChild("HumanoidRootPart") or Char:FindFirstChild("Head")
- end
- function dragEntity(entityModel, pos, speed)
- local entityConnections = EntityConnections[entityModel]
- if entityConnections.movementNode then
- entityConnections.movementNode:Disconnect()
- end
- entityConnections.movementNode = RS.Stepped:Connect(function(_, step)
- if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
- local rootPos = entityModel.PrimaryPart.Position
- local diff = Vector3.new(pos.X, pos.Y, pos.Z) - rootPos
- if diff.Magnitude > 0.1 then
- entityModel:SetPrimaryPartCFrame(CFrame.new(rootPos + diff.Unit * math.min(step * speed, diff.Magnitude)))
- else
- entityConnections.movementNode:Disconnect()
- end
- end
- end)
- repeat task.wait() until not entityConnections.movementNode.Connected
- end
- function loadSound(soundData)
- local sound = Instance.new("Sound")
- local soundId = tostring(soundData[1])
- local properties = soundData[2]
- for i, v in next, properties do
- if i ~= "SoundId" and i ~= "Parent" then
- sound[i] = v
- end
- end
- if soundId:find("rbxasset://") then -- Custom audio
- sound.SoundId = soundId
- else
- local numberId = soundId:gsub("%D", "")
- sound.SoundId = "rbxassetid://".. numberId
- end
- sound.Parent = workspace
- return sound
- end
- -- Functions
- Spawner.createEntity = function(config)
- for i, v in next, SelfModules.DefaultConfig do
- if config[i] == nil then
- config[i] = v
- end
- end
- config.Speed = StaticRushSpeed / 100 * config.Speed
- -- Model
- local entityModel = LoadCustomInstance(config.Model)
- if typeof(entityModel) == "Instance" and entityModel.ClassName == "Model" then
- entityModel.PrimaryPart = entityModel.PrimaryPart or entityModel:FindFirstChildWhichIsA("BasePart")
- if entityModel.PrimaryPart then
- entityModel.PrimaryPart.Anchored = true
- if config.CustomName then
- entityModel.Name = config.CustomName
- end
- entityModel:SetAttribute("IsCustomEntity", true)
- entityModel:SetAttribute("NoAI", false)
- -- EntityTable
- local entityTable = {
- Model = entityModel,
- Config = config,
- Debug = {
- OnEntitySpawned = function() end,
- OnEntityDespawned = function() end,
- OnEntityStartMoving = function() end,
- OnEntityFinishedRebound = function() end,
- OnEntityEnteredRoom = function() end,
- OnLookAtEntity = function() end,
- OnDeath = function() end
- }
- }
- return entityTable
- end
- end
- end
- Spawner.runEntity = function(entityTable)
- -- Nodes
- local entityNodes = {}
- for _, room in next, workspace.CurrentRooms:GetChildren() do
- local nodes = room:WaitForChild("Nodes", 1)
- if nodes then
- nodes = nodes:GetChildren()
- table.sort(nodes, function(a, b)
- return a.Name < b.Name
- end)
- for _, node in next, nodes do
- entityNodes[#entityNodes + 1] = node
- end
- end
- end
- -- Spawn
- local entityModel = entityTable.Model:Clone()
- local startNodeIndex = entityTable.Config.BackwardsMovement and #entityNodes or 1
- local startNodeOffset = entityTable.Config.BackwardsMovement and -50 or 50
- EntityConnections[entityModel] = {}
- local entityConnections = EntityConnections[entityModel]
- entityModel:SetPrimaryPartCFrame(entityNodes[startNodeIndex].CFrame * CFrame.new(0, 0, startNodeOffset) + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0))
- entityModel.Parent = workspace
- task.spawn(entityTable.Debug.OnEntitySpawned)
- -- Mute entity on spawn
- if CG:FindFirstChild("JumpscareGui") or (Plr.PlayerGui.MainUI.Death.HelpfulDialogue.Visible and not Plr.PlayerGui.MainUI.DeathPanelDead.Visible) then
- warn("on death screen, mute entity")
- for _, v in next, entityModel:GetDescendants() do
- if v.ClassName == "Sound" and v.Playing then
- v:Stop()
- end
- end
- end
- -- Flickering
- if entityTable.Config.FlickerLights[1] then
- firesignal(game.ReplicatedStorage.EntityInfo.UseEventModule.OnClientEvent, "flicker", ReSt.GameData.LatestRoom.Value, entityTable.Config.FlickerLights[2])
- end
- -- Movement
- task.wait(entityTable.Config.DelayTime)
- local enteredRooms = {}
- entityConnections.movementTick = RS.Stepped:Connect(function()
- if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
- local entityPos = entityModel.PrimaryPart.Position
- local rootPos = getPlayerRoot().Position
- local floorRay = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, Vector3.new(0, -10, 0)), {entityModel, Char})
- local playerInSight = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, rootPos - entityPos), {entityModel, Char}) == nil
- -- Entered room
- if floorRay ~= nil and floorRay.Name == "Floor" then
- for _, room in next, workspace.CurrentRooms:GetChildren() do
- if floorRay:IsDescendantOf(room) and not table.find(enteredRooms, room) then
- enteredRooms[#enteredRooms + 1] = room
- task.spawn(entityTable.Debug.OnEntityEnteredRoom, room)
- -- Break lights
- if entityTable.Config.BreakLights then
- firesignal(game.ReplicatedStorage.EntityInfo.UseEventModule.OnClientEvent, "shatter", room)
- end
- break
- end
- end
- end
- -- Camera shaking
- local shakeConfig = entityTable.Config.CamShake
- local shakeMag = (getPlayerRoot().Position - entityModel.PrimaryPart.Position).Magnitude
- if shakeConfig[1] and shakeMag <= shakeConfig[3] then
- local shakeRep = {}
- for i, v in next, shakeConfig[2] do
- shakeRep[i] = v
- end
- shakeRep[1] = shakeConfig[2][1] / shakeConfig[3] * (shakeConfig[3] - shakeMag)
- ModuleScripts.MainGame.camShaker.ShakeOnce(ModuleScripts.MainGame.camShaker, table.unpack(shakeRep))
- end
- -- Player in sight
- if playerInSight then
- if game.Players.LocalPlayer.Character:FindFirstChild("Crucifix") then
- local tsa = game:GetService("TweenService")
- entityModel:SetAttribute("NoAI", true)
- local cruxy = game.Players.LocalPlayer.Character.Crucifix.Handle:Clone()
- game.Players.LocalPlayer.Character.Crucifix:Destroy()
- cruxy.Parent = game.Workspace
- cruxy.Name = "cruxy"
- cruxy.Anchored = true
- cruxy.Color = Color3.fromRGB(255, 255, 0)
- cruxy.Material = Enum.Material.Neon
- local cruxeffect = tsa:Create(cruxy, TweenInfo.new(5), {Transparency = 1})
- cruxeffect:Play()
- game.Workspace.Smiley.SmileyNew.NoCollision = true
- wait(2)
- firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'You really thought u can use crucifix on me??',true,7)
- game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
- wait(3)
- firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'You underestimated me.',true,7)
- game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
- wait(2)
- firesignal(game:GetService("ReplicatedStorage").EntityInfo.Caption.OnClientEvent, 'Die.',true,7)
- game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
- local movety = tsa:Create(game.Workspace.Smiley.SmileyNew, TweenInfo.new(2), {Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position})
- movety:Play()
- wait(2)
- 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"}
- local curious = true -- change this to true for it to be the curious guiding light
- local reason = "Smiley" -- Death cause, for ex: "Smiler" would say "You died to Smiler"
- -- SCRIPT, DO NOT TOUCH
- game.Players.LocalPlayer.Character.Humanoid.Health = 0
- if curious == true then
- firesignal(game:GetService("ReplicatedStorage").EntityInfo.DeathHint.OnClientEvent, msg,'Yellow')
- else
- firesignal(game:GetService("ReplicatedStorage").EntityInfo.DeathHint.OnClientEvent, msg,'Blue')
- end
- game.ReplicatedStorage.GameStats["Player_".. game.Players.LocalPlayer.Name].Total.DeathCause.Value = reason
- end
- game.Workspace.Smiley:Destroy()
- -- Look at entity
- local _, onScreen = WorldToViewportPoint(Camera, entityModel.PrimaryPart.Position)
- if onScreen then
- task.spawn(entityTable.Debug.OnLookAtEntity)
- end
- -- Kill player
- 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
- task.spawn(function()
- Char:SetAttribute("IsDead", true)
- -- Mute entity
- warn("mute entity")
- for _, v in next, entityModel:GetDescendants() do
- if v.ClassName == "Sound" and v.Playing then
- v:Stop()
- end
- end
- -- Jumpscare
- if entityTable.Config.Jumpscare[1] then
- Spawner.runJumpscare(entityTable.Config.Jumpscare[2])
- end
- -- Death handling
- task.spawn(entityTable.Debug.OnDeath)
- Hum.Health = 0
- ReSt.GameStats["Player_".. Plr.Name].Total.DeathCause.Value = entityModel.Name
- if #entityTable.Config.CustomDialog > 0 then
- print("Guiding light is currently broken. Message: " ..entityTable.Config.CustomDialog.. " didn't load.")
- end
- -- Unmute entity
- task.spawn(function()
- repeat task.wait() until Plr.PlayerGui.MainUI.DeathPanelDead.Visible
- warn("unmute entity:", entityModel)
- for _, v in next, entityModel:GetDescendants() do
- if v.ClassName == "Sound" then
- local oldVolume = v.Volume
- v.Volume = 0
- v:Play()
- TS:Create(v, TweenInfo.new(2), {Volume = oldVolume}):Play()
- end
- end
- end)
- end)
- end
- end
- end
- end)
- task.spawn(entityTable.Debug.OnEntityStartMoving)
- -- Cycles
- local cyclesConfig = entityTable.Config.Cycles
- if entityTable.Config.BackwardsMovement then
- local inverseNodes = {}
- for nodeIdx = #entityNodes, 1, -1 do
- inverseNodes[#inverseNodes + 1] = entityNodes[nodeIdx]
- end
- entityNodes = inverseNodes
- end
- for cycle = 1, math.max(math.random(cyclesConfig.Min, cyclesConfig.Max), 1) do
- for nodeIdx = 1, #entityNodes, 1 do
- dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
- end
- if cyclesConfig.Max > 1 then
- for nodeIdx = #entityNodes, 1, -1 do
- dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
- end
- end
- -- Rebound finished
- task.spawn(entityTable.Debug.OnEntityFinishedRebound)
- if cycle < cyclesConfig.Max then
- task.wait(cyclesConfig.WaitTime)
- end
- end
- -- Destroy
- if not entityModel:GetAttribute("NoAI") then
- for _, v in next, entityConnections do
- v:Disconnect()
- end
- entityModel:Destroy()
- task.spawn(entityTable.Debug.OnEntityDespawned)
- end
- end
- Spawner.runJumpscare = function(config)
- -- Variables
- local image1 = LoadCustomAsset(config.Image1)
- local image2 = LoadCustomAsset(config.Image2)
- local sound1, sound2 = nil, nil
- if config.Sound1 then
- sound1 = loadSound(config.Sound1)
- end
- if config.Sound2 then
- sound2 = loadSound(config.Sound2)
- end
- -- UI Construction
- local JumpscareGui = Instance.new("ScreenGui")
- local Background = Instance.new("Frame")
- local Face = Instance.new("ImageLabel")
- JumpscareGui.Name = "JumpscareGui"
- JumpscareGui.IgnoreGuiInset = true
- JumpscareGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- Background.Name = "Background"
- Background.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- Background.BorderSizePixel = 0
- Background.Size = UDim2.new(1, 0, 1, 0)
- Background.ZIndex = 999
- Face.Name = "Face"
- Face.AnchorPoint = Vector2.new(0.5, 0.5)
- Face.BackgroundTransparency = 1
- Face.Position = UDim2.new(0.5, 0, 0.5, 0)
- Face.ResampleMode = Enum.ResamplerMode.Pixelated
- Face.Size = UDim2.new(0, 150, 0, 150)
- Face.Image = image1
- Face.Parent = Background
- Background.Parent = JumpscareGui
- JumpscareGui.Parent = CG
- -- Tease
- local teaseConfig = config.Tease
- local absHeight = JumpscareGui.AbsoluteSize.Y
- local minTeaseSize = absHeight / 5
- local maxTeaseSize = absHeight / 2.5
- if teaseConfig[1] then
- local teaseAmount = math.random(teaseConfig.Min, teaseConfig.Max)
- sound1:Play()
- for _ = teaseConfig.Min, teaseAmount do
- task.wait(math.random(100, 200) / 100)
- local growFactor = (maxTeaseSize - minTeaseSize) / teaseAmount
- Face.Size = UDim2.new(0, Face.AbsoluteSize.X + growFactor, 0, Face.AbsoluteSize.Y + growFactor)
- end
- task.wait(math.random(100, 200) / 100)
- end
- -- Flashing
- if config.Flashing[1] then
- task.spawn(function()
- while JumpscareGui.Parent do
- Background.BackgroundColor3 = config.Flashing[2]
- task.wait(math.random(25, 100) / 1000)
- Background.BackgroundColor3 = Color3.new(0, 0, 0)
- task.wait(math.random(25, 100) / 1000)
- end
- end)
- end
- -- Shaking
- if config.Shake then
- task.spawn(function()
- local origin = Face.Position
- while JumpscareGui.Parent do
- Face.Position = origin + UDim2.new(0, math.random(-10, 10), 0, math.random(-10, 10))
- Face.Rotation = math.random(-5, 5)
- task.wait()
- end
- end)
- end
- -- Jumpscare
- Face.Image = image2
- Face.Size = UDim2.new(0, maxTeaseSize, 0, maxTeaseSize)
- sound2:Play()
- TS:Create(Face, TweenInfo.new(0.75), {Size = UDim2.new(0, absHeight * 3, 0, absHeight * 3), ImageTransparency = 0.5}):Play()
- task.wait(0.75)
- JumpscareGui:Destroy()
- if sound1 then
- sound1:Destroy()
- end
- if sound2 then
- sound2:Destroy()
- end
- end
- -- Scripts
- task.spawn(function()
- while true do
- local inSession = false
- for _, v in next, workspace:GetChildren() do
- if v.Name == "RushMoving" or v.Name == "AmbushMoving" or v:GetAttribute("IsCustomEntity") then
- inSession = true
- break
- end
- end
- ReSt.GameData.ChaseInSession.Value = inSession
- task.wait(0.5)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement