Advertisement
TaylorsRus

Untitled

Nov 29th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.07 KB | None | 0 0
  1. local OmnitrixFunctions = {}
  2.  
  3. -- // Services
  4.  
  5. local RepStorage = game:GetService("ReplicatedStorage")
  6. local SS = game:GetService("ServerStorage")
  7.  
  8.     -- // Modules
  9.    
  10. local OmnitrixData = require(RepStorage.Modules.OmnitrixData)
  11.  
  12. -- // Constants
  13.  
  14. -- // Instance Variables
  15.  
  16. local AnimFolder = RepStorage:WaitForChild("Animations").Omnitrix
  17.  
  18. -- // Other Variables
  19.  
  20. local PlaceNewChar = CFrame.new(0, -2, 0)
  21. local DeTransforming = false
  22.  
  23. local function ChangeStats(char, Alien)
  24.    
  25.     local Index = OmnitrixData.AlienData[Alien.Name]
  26.    
  27.     char:WaitForChild("Humanoid").WalkSpeed = Index["WalkSpeed"]
  28.     char:SetAttribute("WalkSpeed", Index["WalkSpeed"])
  29.     char:SetAttribute("RunSpeed", Index["RunSpeed"])
  30.     char:SetAttribute("MeleeDamage", (char:GetAttribute("MeleeDamage") * Index["CombatMultiplier"]))
  31.     char:SetAttribute("OmnitrixStatus", "Transformed")
  32.     char:SetAttribute("CurrentAlien", Alien.Name)
  33.    
  34. end
  35.  
  36. local function TurnDial(char, Max, Min, Direction)
  37.    
  38.     local function SetAtt(Maths)
  39.         local SetAtt = char:SetAttribute("SelectedAlien", Maths)
  40.     end
  41.    
  42.     if Direction == "Right" then
  43.        
  44.         if (char:GetAttribute("SelectedAlien") + 1) < Max then
  45.             SetAtt(char:GetAttribute("SelectedAlien") + 1)
  46.         else
  47.             SetAtt(1)
  48.         end
  49.        
  50.     elseif Direction == "Left" then
  51.    
  52.         if (char:GetAttribute("SelectedAlien") - 1) > Min then
  53.             SetAtt(char:GetAttribute("SelectedAlien") - 1)
  54.         else
  55.             SetAtt(10)
  56.         end
  57.     end
  58. end
  59.  
  60. function OmnitrixFunctions.Activate(char, humrp)
  61.            
  62.     char = char or error("No character exists")
  63.    
  64.     if char:GetAttribute("OmnitrixStatus") == "Transformed" then return end
  65.            
  66.     if char:GetAttribute("OmnitrixStatus") == "Down" then
  67.        
  68.         local ActivateSound = humrp:WaitForChild("OmnitrixDialUp")
  69.         ActivateSound:Play()
  70.        
  71.         task.wait(.5)
  72.        
  73.         char:SetAttribute("SelectedAlien", 1)
  74.         char:SetAttribute("OmnitrixStatus", "Up")
  75.            
  76.         print("Alien selected is "..OmnitrixData.Aliens[char:GetAttribute("SelectedAlien")])
  77.  
  78.     elseif char:GetAttribute("OmnitrixStatus") == "Up" then
  79.  
  80.         char:SetAttribute("SelectedAlien", nil)
  81.         char:SetAttribute("OmnitrixStatus", "Down")
  82.         humrp:WaitForChild("Tick"):Play()
  83.            
  84.         print("Omnitrix down.")
  85.        
  86.     end    
  87. end
  88.  
  89. function OmnitrixFunctions.Turn(char, humrp, Direction)
  90.    
  91.     char = char or error("No character exists")
  92.        
  93.     if char:GetAttribute("OmnitrixStatus") == "Transformed" or char:GetAttribute("OmnitrixStatus") == "Down" then return end
  94.    
  95.     local LastAlien = 10
  96.     local FirstAlien = 1
  97.    
  98.     TurnDial(char, LastAlien, FirstAlien, Direction)       
  99.     humrp:WaitForChild("OmnitrixSwitch"..math.random(1, 2)):Play()
  100.  
  101.     print("From turning "..Direction.." you are now on "..OmnitrixData.Aliens[char:GetAttribute("SelectedAlien")])
  102. end
  103.    
  104. function OmnitrixFunctions.Transform(char, humrp)
  105.  
  106.     local plr = game.Players:GetPlayerFromCharacter(char) or error("No player exists for this Character.")
  107.    
  108.     if char:GetAttribute("OmnitrixStatus") == "Transformed" or char:GetAttribute("OmnitrixStatus") == "Recharging" then return end
  109.    
  110.     if char then
  111.  
  112.         local TransformAnim = char:WaitForChild("Humanoid").Animator:LoadAnimation(AnimFolder:WaitForChild("Transform"))
  113.         TransformAnim:Play()   
  114.  
  115.         local AlienFolder = SS:WaitForChild("Assets").Models.AlienModels   
  116.         local Alien = AlienFolder:WaitForChild(OmnitrixData.Aliens[char:GetAttribute("SelectedAlien")]):Clone()
  117.        
  118.         if Alien then
  119.             Alien.HumanoidRootPart.Anchored = false
  120.             Alien:WaitForChild("HumanoidRootPart").CFrame = humrp.CFrame * PlaceNewChar
  121.         else
  122.             error("No alien available for this integer value.")
  123.         end
  124.        
  125.         if char:GetAttribute("OmnitrixStatus") == "Down" then
  126.             char:SetAttribute("SelectedAlien", (math.random(1, #AlienFolder:GetChildren())))
  127.         end
  128.        
  129.         task.wait(.5)
  130.        
  131.         char.Archivable = true
  132.        
  133.         local CharClone = char:Clone()
  134.         CharClone.Parent = plr
  135.        
  136.         if char:GetAttribute("OmnitrixStatus") == "Down"  then
  137.             char:SetAttribute("SelectedAlien", (math.random(1, #AlienFolder:GetChildren())))
  138.         end
  139.  
  140.         for _,Guts in pairs(char:GetChildren()) do
  141.  
  142.             if Guts:IsA("Script") or Guts:IsA("LocalScript") or Guts:IsA("Folder") or Guts:IsA("Humanoid") then
  143.                
  144.                 Guts:Clone().Parent = Alien
  145.                
  146.             elseif Guts:IsA("BasePart") and Guts.Name == "HumanoidRootPart" then
  147.        
  148.                 for _,RootAssets in pairs(Guts:GetChildren()) do
  149.        
  150.                     RootAssets:Clone().Parent = Alien.HumanoidRootPart
  151.                 end    
  152.             end
  153.         end
  154.        
  155.         plr.Character = Alien
  156.         Alien.Parent = workspace:WaitForChild("LivingThings")
  157.        
  158.         char:Destroy()
  159.         char = plr.Character
  160.         humrp = char:WaitForChild("HumanoidRootPart")
  161.        
  162.         humrp:WaitForChild("OmnitrixTransform"):Play() 
  163.         humrp:WaitForChild("OmnitrixTransformEffect"):Emit(35)
  164.         ChangeStats(char, Alien)
  165.        
  166.         print("You are now ".. Alien.Name..".")
  167.        
  168.         for i = 1, 600 do      
  169.             task.wait(1)
  170.            
  171.             if DeTransforming then break end   
  172.             if i == 600 then OmnitrixFunctions:UnTransform(char) end
  173.         end
  174.     else
  175.         print("No Character exists.")
  176.     end
  177. end
  178.  
  179. function OmnitrixFunctions.DeTransform(char)
  180.  
  181.     local plr = game.Players:GetPlayerFromCharacter(char) or error("No Player exists for this Character.")
  182.     local humrp = char:WaitForChild("HumanoidRootPart") or error("No HumanoidRootPart exists for this character.") 
  183.  
  184.     if DeTransforming or char:GetAttribute("OmnitrixStatus") ~= "Transformed" then return end
  185.  
  186.     DeTransforming = true
  187.  
  188.     local OrigChar = plr:WaitForChild(plr.Name)
  189.    
  190.     if OrigChar then
  191.    
  192.         local DeTransform = humrp:WaitForChild("OmnitrixDeTransform")
  193.         DeTransform:Play()
  194.        
  195.         task.wait(3.5)
  196.  
  197.         OrigChar:WaitForChild("HumanoidRootPart").CFrame = humrp.CFrame * PlaceNewChar
  198.        
  199.         char:WaitForChild("Humanoid").Parent = OrigChar
  200.         plr.Character = OrigChar
  201.         OrigChar.Parent = workspace:WaitForChild("LivingThings")
  202.  
  203.         char:Destroy()
  204.         char = plr.Character
  205.         humrp = char:WaitForChild("HumanoidRootPart")
  206.  
  207.         humrp:WaitForChild("OmnitrixDeTransformEffect"):Emit(35)
  208.         humrp:WaitForChild("OmnitrixTransform"):Play()
  209.  
  210.         char:SetAttribute("OmnitrixState", "Down") 
  211.         char:SetAttribute("CurrentAlien", "Base")
  212.        
  213.         DeTransforming = false
  214.     else
  215.         print("No Character of this name exists in the Player.")
  216.     end
  217. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement