TitanModule
unknown
lua
6 months ago
12 kB
3
Indexable
Never
local Titans = {"ErenFoundingTitan"} local AnimFolder = game:GetService("ReplicatedStorage"):WaitForChild("TitanOSReplicatedStorage"):WaitForChild("Animations") local Debris = game:GetService("Debris") local Storage = game:GetService("ReplicatedStorage"):WaitForChild("TitanOSReplicatedStorage") local Remotes = Storage:WaitForChild("Remotes") local TitanEvent = Remotes:WaitForChild("Effects") local Cam = Remotes:WaitForChild("Camera") local Runservice = game:GetService("RunService") local PhysicsService = game:GetService("PhysicsService") local Group = "Titans" PhysicsService:CreateCollisionGroup(Group) PhysicsService:CollisionGroupSetCollidable(Group,Group,true) local Animation_Module = require(Storage:WaitForChild("Modules"):WaitForChild("Animation")) local function Face_Direction(Character,Direction) local HRMP = Character.PrimaryPart HRMP.CFrame = CFrame.new(HRMP.CFrame.Position,Direction.Position) end function Alignments(character) local HRMP = character.PrimaryPart local Align_Position = Instance.new("AlignPosition",HRMP) local PA,PO = Instance.new("Attachment",HRMP),Instance.new("Attachment",HRMP) Align_Position.Mode = Enum.PositionAlignmentMode.OneAttachment Align_Position.Attachment0 = PA Align_Position.MaxForce = math.huge Align_Position.MaxVelocity = math.huge Align_Position.Responsiveness = 200 Align_Position.Position = HRMP.Position local Align_Orientation = Instance.new("AlignOrientation",HRMP) Align_Orientation.Mode = Enum.OrientationAlignmentMode.OneAttachment Align_Orientation.Attachment0 = PO Align_Orientation.MaxTorque = math.huge Align_Orientation.Responsiveness = 200 Align_Orientation.CFrame = HRMP.CFrame * CFrame.Angles(0,math.rad(90),0) return Align_Position,Align_Orientation end function GetTitans(titanname) local IfTitan = game:GetService("ReplicatedStorage"):WaitForChild("TitanOSReplicatedStorage"):WaitForChild("Titans"):FindFirstChild(titanname,true) local Titan if IfTitan then warn('Titan does exits') Titan = IfTitan:Clone() else warn(Titan..": Doesn't exist") return end return Titan end function GetAnimationFolder(TitansName) local TitanAnimations if AnimFolder:FindFirstChild(TitansName,true) then TitanAnimations = AnimFolder:FindFirstChild(TitansName,true) else warn('titan doesnt have animation;failsafe') TitanAnimations = AnimFolder:FindFirstChild("AttackTitan",true) end return TitanAnimations end function Exit(player,Titan) local Nape = Titan:WaitForChild("UpperTorso"):FindFirstChild("Nape") if Nape == nil then warn("Model/Titan doesn't have a 'Nape' ") player:LoadCharacter() TitanEvent:FireAllClients(player,Titan,"Decay") TitanEvent:FireClient(player,nil,nil,"EnableControls") return end TitanEvent:FireClient(player,nil,nil,"DisableControls") TitanEvent:FireAllClients(player,Titan,"AddToCollisionGroup") player:LoadCharacter() local character = player.Character character.PrimaryPart.CFrame = Nape.CFrame local NeckWeld = Instance.new("Weld",Nape) --This is just incase things break local Loaded = false task.spawn(function() task.wait(7) if not Loaded then warn('Fixing') NeckWeld:Destroy() TitanEvent:FireAllClients(player,Titan,"Decay") TitanEvent:FireClient(player,nil,nil,"EnableControls") end end) Nape.Transparency = 0 NeckWeld.Part0 = Nape NeckWeld.Part1 = character.PrimaryPart NeckWeld.C0 = Nape.CFrame:ToObjectSpace(Nape.CFrame* CFrame.new(0,0,3) * CFrame.Angles(math.rad(110),0,0)) NeckWeld.C1 = Nape.CFrame:ToObjectSpace(Nape.CFrame* CFrame.new(0,2,0)) local Track2 = player.Character.Humanoid:LoadAnimation(Storage:WaitForChild("Animations").Character.Exit) Track2:Play() local SquishSound = Storage:WaitForChild("Sounds"):FindFirstChild("Squish",true):Clone() Debris:AddItem(SquishSound,7) SquishSound.Parent = player.Character SquishSound:Play() lock(player.Character.Humanoid,5) Animation_Module.Marker(player.Character.Humanoid,"Exit","Exit",function() Loaded = true NeckWeld:Destroy() TitanEvent:FireAllClients(player,Titan,"Decay") TitanEvent:FireClient(player,nil,nil,"EnableControls") end) end function lock(humanoid,t) local ws,jp = humanoid.WalkSpeed,humanoid.JumpPower--,humanoid.AutoRotate task.delay(t,function() humanoid.WalkSpeed = ws humanoid.JumpPower = jp humanoid.AutoRotate = true end) humanoid.WalkSpeed = 0 humanoid.JumpPower = 0 humanoid.AutoRotate = false end function GetUnshiftedTitan(player) local Titan = player.Character:Clone() local TitansName = Titan.Name Debris:AddItem(Titan,30) Titan.PrimaryPart.CFrame = player.Character.PrimaryPart.CFrame Titan.Parent = player.Character.Parent player.Character:Destroy() Cam:FireClient(player,"swap",Titan.Humanoid) return Titan end Titans["ErenFoundingTitan"] = function(player,TitansName) local char = player.Character local hum = char.Humanoid local HRMP = char.HumanoidRootPart local Zeke = Storage:WaitForChild("Extra").Zeke:Clone() local Gabi = Storage:WaitForChild("Extra").FAZE_Gabi:Clone() local Neck = Storage:WaitForChild("Extra").Neck:Clone() Debris:AddItem(Zeke,25) Debris:AddItem(Gabi,25) Zeke.Parent = game.Workspace Gabi.Parent = game.Workspace Zeke.PrimaryPart:SetNetworkOwner(player) Gabi.PrimaryPart:SetNetworkOwner(player) hum.AutoRotate = false player.Character.PrimaryPart.Anchored = true Zeke.PrimaryPart.Anchored = true Gabi.PrimaryPart.Anchored = true task.wait(1) Zeke.PrimaryPart.CFrame = HRMP.CFrame * CFrame.new(0,0,-100) Zeke.PrimaryPart.CFrame = CFrame.new(Zeke.PrimaryPart.CFrame.Position , HRMP.CFrame.Position) Gabi.PrimaryPart.CFrame = HRMP.CFrame:Lerp(Zeke.PrimaryPart.CFrame ,.5) * CFrame.new(0,0,60) Gabi.PrimaryPart.CFrame = CFrame.new(Gabi.PrimaryPart.CFrame.Position , HRMP.CFrame:Lerp(Zeke.PrimaryPart.CFrame ,.5).Position) Neck.Parent = char.UpperTorso local face local motor = Instance.new("Motor6D",player.Character.UpperTorso) motor.Part0 = char.UpperTorso motor.Part1 = Neck.MainPart motor.C0 = CFrame.new(-0.0243835449, 0.182054996, 0.0381164551, 0, 1.25575325e-30, -1, 5.48907162e-38, 1, 1.25575325e-30, 1, -5.48907162e-38, 0 ) task.wait() local leave_alone = Instance.new("Folder",game.Workspace) leave_alone.Name = "leave_alone" Debris:AddItem(leave_alone,20) Instance.new("ObjectValue",leave_alone).Value = Gabi Instance.new("ObjectValue",leave_alone).Value = char Instance.new("ObjectValue",leave_alone).Value = Zeke TitanEvent:FireAllClients(player,nil,"ErenFoundingTitan",{true,1,{Gabi:GetDescendants(),Zeke:GetDescendants(),char:GetDescendants() }}) -- TitanEvent:FireAllClients(player,nil,"SetPos",{Zeke,Zeke.PrimaryPart.CFrame}) -- TitanEvent:FireAllClients(player,nil,"SetPos",{Gabi,Gabi.PrimaryPart.CFrame}) local track_1 = Animation_Module.Animate(hum,AnimFolder["ErenFoundingTitan"],"Intro") local track_2 = Animation_Module.Animate(Zeke.Humanoid,AnimFolder["ErenFoundingTitan"],"Zeke") local track_3 = Animation_Module.Animate(Gabi.Humanoid,AnimFolder["ErenFoundingTitan"],"Gabi") local track_4 = Animation_Module.Animate(Neck.AnimationController,AnimFolder["ErenFoundingTitan"],"Neck") Animation_Module.Marker(hum,"Intro","Nape",function() Neck["Cube.059"].Transparency = 0 end) Animation_Module.Marker(hum,"Intro","Connect",function() track_1:AdjustSpeed(0) track_2:AdjustSpeed(0) track_3:AdjustSpeed(0) track_4:AdjustSpeed(0) task.wait(9) local Eren_Titan = Storage:WaitForChild("Titans"):WaitForChild("Attack_Varients"):WaitForChild("Eren_AttackTitan"):Clone() Eren_Titan.Parent = game.Workspace Eren_Titan:PivotTo(char.PrimaryPart.CFrame * CFrame.new(0,100,0)) player.Character = Eren_Titan player.CameraMaxZoomDistance = 1000 for _,scripts in ipairs(Storage:WaitForChild("TitanScripts"):WaitForChild("Global"):GetChildren()) do --if scripts:IsA("Script") or scripts:IsA("LocalScript") then scripts:Clone().Parent = Eren_Titan --end end print("Global, Loaded!") end) end Titans.Shift = function(player,TitansName) print(TitansName) if table.find(Titans,TitansName) then Titans[TitansName](player,TitansName) return end local Titan = GetTitans(TitansName) if Titan ~= nil then local TitanHumanoid = Titan:FindFirstChildOfClass("Humanoid") TitanHumanoid.AutoRotate = false TitanHumanoid.BreakJointsOnDeath = false TitanHumanoid.RequiresNeck = false local PrimaryPart = Titan.PrimaryPart lock(TitanHumanoid,3) local Torque = Instance.new("AlignPosition",PrimaryPart) Torque.Mode = Enum.PositionAlignmentMode.OneAttachment Torque.Attachment0 = Instance.new("Attachment",PrimaryPart) PrimaryPart.CFrame = player.Character.PrimaryPart.CFrame * CFrame.new(0,TitanHumanoid.HipHeight + TitanHumanoid.HipHeight/2,0) Torque.Position = (player.Character.PrimaryPart.CFrame * CFrame.new(0,TitanHumanoid.HipHeight + TitanHumanoid.HipHeight/2 ,0)).Position Torque.MaxForce = math.huge Debris:AddItem(Torque,3) Titan.Parent = player.Character.Parent Cam:FireClient(player,"swap",TitanHumanoid) player.Character = Titan TitanEvent:FireAllClients(player,Titan,"Flesh",{true,1}) local TitanAnimations = GetAnimationFolder(TitansName) Animation_Module.Animate(TitanHumanoid,TitanAnimations,"Intro") for _,scripts in ipairs(Storage:WaitForChild("TitanScripts"):WaitForChild("Global"):GetChildren()) do --if scripts:IsA("Script") or scripts:IsA("LocalScript") then scripts:Clone().Parent = Titan --end end print("Global, Loaded!") if Storage:WaitForChild("TitanScripts"):FindFirstChild(TitansName) then local t = Storage:WaitForChild("TitanScripts"):FindFirstChild(TitansName) for _,scripts in ipairs(t:GetChildren()) do scripts:Clone().Parent = Titan end print(TitansName..": scripts have been loaded!") else warn(TitansName.." scripts aren't found or exist") end else warn('Error has occured') end end Titans.UnShift = function(player) local Titan = GetUnshiftedTitan(player) local TitansName = Titan.Name if Titan ~= nil then local TitanHumanoid = Titan:FindFirstChildOfClass("Humanoid") local PrimaryPart = Titan.PrimaryPart local Exited = false lock(TitanHumanoid,10) local TitanAnimations = GetAnimationFolder(TitansName) Cam:FireClient(player,"swap",Titan.Head) Animation_Module.Animate(TitanHumanoid,TitanAnimations,"UnShift") Animation_Module.Marker(TitanHumanoid,"UnShift","Exit",function() Animation_Module.AdjustSpeed(TitanHumanoid,"UnShift",0) Exited = true Exit(player,Titan) end) warn("Bypassed") task.spawn(function() task.wait(5) if Exited then print('already leaving') else Exit(player,Titan) end end) repeat task.wait() until Exited == true if Exited then return end else warn('Error has occured') end end Titans.Death = function(player) local Titan = GetUnshiftedTitan(player) local TitansName = Titan.Name print("death") if Titan ~= nil then local TitanHumanoid = Titan:FindFirstChildOfClass("Humanoid") local PrimaryPart = Titan.PrimaryPart lock(TitanHumanoid,10) Cam:FireClient(player,"swap",Titan.Head) local TitanAnimations = GetAnimationFolder(TitansName) Animation_Module.Animate(TitanHumanoid,TitanAnimations,"Outro") local Exited = false task.spawn(function() task.wait(5) if Exited then print('already leaving') else Exit(player,Titan) end end) Animation_Module.Marker(TitanHumanoid,"Outro","Death",function() Animation_Module.AdjustSpeed(TitanHumanoid,"Outro",0) Exited = true Exit(player,Titan) end) else warn('Error has occured') end end return Titans