Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- 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 bpos = Instance.new("BodyPosition")
- local LocalPlayer = game.Players.suremark
- local height = 0
- local bin = Instance.new("HopperBin", LocalPlayer.Backpack)
- bin.Name = "Levitate"
- local gravitating = false
- local box
- local target
- bin.Selected:connect(function(mouse)
- Spawn(function()
- local parts;
- while wait() do
- box = box and box:Destroy() or nil
- box = Instance.new("SelectionBox", LocalPlayer.PlayerGui)
- box.Adornee = target
- bpos.position = mouse.Hit.p + Vector3.new(0, height, 0)
- bpos.maxForce = mouse.Target and Vector3.new(1, 1, 1) * mouse.Target:GetMass()^2 or Vector3.new()
- if target then
- parts = DrawLightning(LocalPlayer.Character.Head.Position + Vector3.new(0, 2, 0), target.Position, 32, BrickColor.new 'Really red');
- for _, part in next, parts do game.Debris:AddItem(part, 0.05); end
- end
- end
- end)
- mouse.Button1Down:connect(function()
- if not mouse.Target then return end
- gravitating = true
- bpos.Parent = mouse.Target
- target = mouse.Target
- end)
- mouse.Button1Up:connect(function()
- gravitating = false
- bpos.Parent = nil
- target = nil
- end)
- mouse.KeyDown:connect(function(key)
- if not gravitating then return end
- if key:lower() == "e" then
- local running = true
- Spawn(function()
- while wait() and running do
- height = height + 1
- end
- end)
- repeat until mouse.KeyUp:wait():lower() == "e"
- running = false
- elseif key:lower() == "q" then
- local running = true
- Spawn(function()
- while wait() and running do
- height = height - 1
- end
- end)
- repeat until mouse.KeyUp:wait():lower() == "q"
- running = false
- end
- end)
- end)
- bin.Deselected:connect(function()
- bpos.Parent = nil
- target = nil
- box = box and box:Destroy() or nil
- gravitating = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement