Advertisement
suremarc

Untitled

Mar 29th, 2015
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 KB | None | 0 0
  1. local debugMode = true
  2.  
  3. if not debugMode then print = function()end end
  4.  
  5. local DrawLine = function(v1, v2, color)
  6.     local part = Instance.new("Part", Workspace)
  7.     Instance.new("BlockMesh", part).Scale = Vector3.new(0.3, 0.3, (v1 - v2).magnitude)
  8.     part.Size = Vector3.new()
  9.     part.BrickColor = color
  10.     part.formFactor = "Symmetric"
  11.     part.CFrame = CFrame.new(v1:Lerp(v2, 0.5), v2)
  12.     part.Anchored = true
  13.     part.CanCollide = false
  14.     return part
  15. end
  16.  
  17. local DrawBall = function(v, r, color)
  18.     local part = Instance.new("Part", Workspace)
  19.     part.Size = Vector3.new(2, 2, 2) * r
  20.     part.BrickColor = color
  21.     part.formFactor = "Symmetric"
  22.     part.Shape = "Ball"
  23.     part.CFrame = CFrame.new(v)
  24.     part.Anchored = true
  25.     part.CanCollide = false
  26.     part.TopSurface = "Smooth"
  27.     part.BottomSurface = "Smooth"
  28.     return part
  29. end
  30.  
  31. local function get_character(descendant)
  32.     -- Returns a character from one of its descendants.
  33.     local character = descendant
  34.     repeat
  35.         if character.Parent then
  36.             character = character.Parent
  37.         else
  38.             return nil
  39.         end
  40.     until Players:GetPlayerFromCharacter(character)
  41.     return character
  42. end
  43.  
  44. local function DrawLightning(v1, v2, displace, color)
  45.     local parts = {}
  46.  
  47.     local function recurse(v1, v2, displace, color)
  48.         if displace < 1 then
  49.             table.insert(parts, DrawLine(v1, v2, color))
  50.         else
  51.             local midpoint = (v1 + v2) / 2
  52.             midpoint = midpoint + Vector3.new((math.random() - 0.5) * displace, (math.random() - 0.5) * displace, (math.random() - 0.5) * displace)
  53.             recurse(v1, midpoint, displace/2, color)
  54.             recurse(v2, midpoint, displace/2, color)
  55.         end
  56.     end
  57.    
  58.     recurse(v1, v2, displace, color)
  59.    
  60.     table.sort(parts, function(a, b)
  61.         return (v1 - a.Position).magnitude < (v1 - b.Position).magnitude
  62.     end)
  63.     return parts
  64. end
  65.  
  66. local mousedown = false
  67.  
  68. local Force = {
  69.     ["Push"] = function(jedi, target)
  70.         if not target then return end
  71.         if target.Anchored then return end
  72.         while mousedown do wait() target.Velocity = CFrame.new(jedi:GetModelCFrame().p, target.CFrame.p).lookVector * target:GetMass()^0.5 * 4 end
  73.     end;
  74.     ["Pull"] = function(jedi, target)
  75.         if not target then return end
  76.         if target.Anchored then return end
  77.         while mousedown do wait() target.Velocity = CFrame.new(jedi:GetModelCFrame().p, target.CFrame.p).lookVector * -target:GetMass()^0.5 * 4 end
  78.     end;
  79.     ["Jump"] = function(jedi)
  80.         while mousedown do wait() jedi.Torso.Velocity = Vector3.new(0, 50, 0) end
  81.     end;
  82.     ["Lightning"] = function(jedi, target)
  83.         if not target then return end
  84.         while mousedown do
  85.             print 'lightning'
  86.             local lightning = DrawLightning(jedi:GetModelCFrame().p, target.CFrame.p, 16, BrickColor.new("Really red"))
  87.             pcall(function() local char = get_character(target) char.Humanoid.Health = char.Humanoid.Health - 1 end)
  88.             wait()
  89.             for i, v in pairs(lightning) do v:Destroy() end
  90.         end
  91.     end;
  92.     ["Mind Control"] = function(jedi, target)
  93.         local target = target and get_character(target)
  94.         if not target then return end
  95.         jedi.Character = target and target.Character or jedi.Character
  96.     end;
  97. }
  98.  
  99. local modes = {}
  100. for i, _ in pairs(Force) do table.insert(modes, i) end
  101. Force.Modes = modes
  102. modes = nil
  103.  
  104. local LocalPlayer = game.Players.LocalPlayer
  105. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait()
  106.  
  107. local bin = Instance.new("HopperBin", LocalPlayer.Backpack)
  108. bin.Selected:connect(function(mouse)
  109.     local key = 1
  110.     bin.Name = "Push"
  111.     local SetKey = function(n)
  112.         if n < 1 or n > #Force.Modes then return end
  113.         print("setting key to " .. n)
  114.         key = n
  115.         bin.Name = Force.Modes[key]
  116.     end
  117.        
  118.     mouse.Button1Down:connect(function()
  119.         mousedown = true
  120.         print("mouse down")
  121.         print(Force.Modes[key] .. " activated")
  122.         Force[Force.Modes[key]](Character, mouse.Target)
  123.     end)
  124.    
  125.     mouse.Button1Up:connect(function()
  126.         mousedown = false
  127.         print("mouse up")
  128.     end)
  129.    
  130.     mouse.KeyDown:connect(function(k)
  131.         print(k .. " pressed")
  132.         k = k:lower()
  133.         if k == "q" then
  134.             SetKey(key - 1)
  135.         elseif k == "e" then
  136.             SetKey(key + 1)
  137.         end
  138.     end)
  139. end)
  140.  
  141. bin.Deselected:connect(function()
  142.     mousedown = false
  143. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement