Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local debugMode = true
- if not debugMode then print = function()end end
- local DrawLine = function(v1, v2, color)
- local part = Instance.new("Part", Workspace)
- Instance.new("BlockMesh", part).Scale = Vector3.new(0.3, 0.3, (v1 - v2).magnitude)
- part.Size = Vector3.new()
- part.BrickColor = color
- part.formFactor = "Symmetric"
- part.CFrame = CFrame.new(v1:Lerp(v2, 0.5), v2)
- part.Anchored = true
- part.CanCollide = false
- return part
- end
- local DrawBall = function(v, r, color)
- local part = Instance.new("Part", Workspace)
- part.Size = Vector3.new(2, 2, 2) * r
- part.BrickColor = color
- part.formFactor = "Symmetric"
- part.Shape = "Ball"
- part.CFrame = CFrame.new(v)
- part.Anchored = true
- part.CanCollide = false
- part.TopSurface = "Smooth"
- part.BottomSurface = "Smooth"
- return part
- end
- local function get_character(descendant)
- -- Returns a character from one of its descendants.
- local character = descendant
- repeat
- if character.Parent then
- character = character.Parent
- else
- return nil
- end
- until Players:GetPlayerFromCharacter(character)
- return character
- end
- local function DrawLightning(v1, v2, displace, color)
- local parts = {}
- local function recurse(v1, v2, displace, color)
- if displace < 1 then
- table.insert(parts, DrawLine(v1, v2, color))
- else
- local midpoint = (v1 + v2) / 2
- midpoint = midpoint + Vector3.new((math.random() - 0.5) * displace, (math.random() - 0.5) * displace, (math.random() - 0.5) * displace)
- recurse(v1, midpoint, displace/2, color)
- recurse(v2, midpoint, displace/2, color)
- end
- end
- recurse(v1, v2, displace, color)
- table.sort(parts, function(a, b)
- return (v1 - a.Position).magnitude < (v1 - b.Position).magnitude
- end)
- return parts
- end
- local mousedown = false
- local Force = {
- ["Push"] = function(jedi, target)
- if not target then return end
- if target.Anchored then return end
- while mousedown do wait() target.Velocity = CFrame.new(jedi:GetModelCFrame().p, target.CFrame.p).lookVector * target:GetMass()^0.5 * 4 end
- end;
- ["Pull"] = function(jedi, target)
- if not target then return end
- if target.Anchored then return end
- while mousedown do wait() target.Velocity = CFrame.new(jedi:GetModelCFrame().p, target.CFrame.p).lookVector * -target:GetMass()^0.5 * 4 end
- end;
- ["Jump"] = function(jedi)
- while mousedown do wait() jedi.Torso.Velocity = Vector3.new(0, 50, 0) end
- end;
- ["Lightning"] = function(jedi, target)
- if not target then return end
- while mousedown do
- print 'lightning'
- local lightning = DrawLightning(jedi:GetModelCFrame().p, target.CFrame.p, 16, BrickColor.new("Really red"))
- pcall(function() local char = get_character(target) char.Humanoid.Health = char.Humanoid.Health - 1 end)
- wait()
- for i, v in pairs(lightning) do v:Destroy() end
- end
- end;
- ["Mind Control"] = function(jedi, target)
- local target = target and get_character(target)
- if not target then return end
- jedi.Character = target and target.Character or jedi.Character
- end;
- }
- local modes = {}
- for i, _ in pairs(Force) do table.insert(modes, i) end
- Force.Modes = modes
- modes = nil
- local LocalPlayer = game.Players.LocalPlayer
- local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait()
- local bin = Instance.new("HopperBin", LocalPlayer.Backpack)
- bin.Selected:connect(function(mouse)
- local key = 1
- bin.Name = "Push"
- local SetKey = function(n)
- if n < 1 or n > #Force.Modes then return end
- print("setting key to " .. n)
- key = n
- bin.Name = Force.Modes[key]
- end
- mouse.Button1Down:connect(function()
- mousedown = true
- print("mouse down")
- print(Force.Modes[key] .. " activated")
- Force[Force.Modes[key]](Character, mouse.Target)
- end)
- mouse.Button1Up:connect(function()
- mousedown = false
- print("mouse up")
- end)
- mouse.KeyDown:connect(function(k)
- print(k .. " pressed")
- k = k:lower()
- if k == "q" then
- SetKey(key - 1)
- elseif k == "e" then
- SetKey(key + 1)
- end
- end)
- end)
- bin.Deselected:connect(function()
- mousedown = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement