Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = Instance.new("Tool", game.Players.PabloRV.Backpack)
- local Launcher = Instance.new("Script",tool)Launcher.Name = "Launcher"
- Launcher.Source = [[Tool = script.Parent
- thrown = true
- VELOCITY = 40
- function Nade()
- local model = Instance.new("Model")
- model.Name = "Nade"
- model.Parent = game.Workspace
- nade = Tool.Handle:clone()
- nade1 = Tool.Handle1:clone()
- nade2 = Tool.Handle2:clone()
- nade3 = Tool.Handle3:clone()
- nade.Parent = model
- nade1.Parent = model
- nade2.Parent = model
- nade3.Parent = model
- nade.CanCollide = true
- nade1.CanCollide = true
- nade2.CanCollide = true
- nade3.CanCollide = true
- local script = Tool.NadeScript:clone()
- script.Disabled = false
- script.Parent = nade
- return model
- end
- function lob(mousepos)
- local vCharacter = Tool.Parent
- local vPlayer = game.Players:playerFromCharacter(vCharacter)
- local head = Tool:findFirstChild("Handle")
- if head == nil then return end
- local dir = mousepos - head.Position
- dir = computeDirection(dir)
- local launch = head.Position + 10 * dir
- local delta = mousepos - launch
- local dy = delta.y
- local new_delta = Vector3.new(delta.x, 0, delta.z)
- delta = new_delta
- local dx = delta.magnitude
- local unit_delta = delta.unit
- local g = (-9.81 * 20)
- local theta = computeLaunchAngle(dx, dy, g)
- local vy = math.sin(theta)
- local xz = math.cos(theta)
- local vx = unit_delta.x * xz
- local vz = unit_delta.z * xz
- local missile = Nade()
- missile.Handle.Position = launch
- missile.Handle.Velocity = Vector3.new(vx, vy, vz) * VELOCITY
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = vPlayer
- creator_tag.Name = "creator"
- creator_tag.Parent = missile.Handle
- end
- function computeLaunchAngle(dx, dy, grav)
- -- http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
- local g = math.abs(grav)
- local inRoot = (VELOCITY*VELOCITY*VELOCITY*VELOCITY) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
- if inRoot <= 0 then
- return .25 * math.pi
- end
- local root = math.sqrt(inRoot)
- local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)
- local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
- local answer1 = math.atan(inATan1)
- local answer2 = math.atan(inATan2)
- if answer1 < answer2 then return answer1 end
- return answer2
- end
- function computeDirection(vec)
- local lenSquared = vec.magnitude * vec.magnitude
- local invSqrt = 1 / math.sqrt(lenSquared)
- return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
- end
- function Weld(parentObj)
- local w1 = Instance.new("Weld")
- local w2 = Instance.new("Weld")
- local w3 = Instance.new("Weld")
- w1.Parent = parentObj.Handle
- w2.Parent = parentObj.Handle
- w3.Parent = parentObj.Handle
- w1.Part0 = w1.Parent
- w2.Part0 = w2.Parent
- w3.Part0 = w3.Parent
- w1.Part1 = parentObj.Handle1
- w2.Part1 = parentObj.Handle2
- w3.Part1 = parentObj.Handle3
- w1.C1 = CFrame.new(0, -0.5, 0)
- w2.C1 = CFrame.new(0, -0.6, 0)
- w3.C1 = CFrame.new(-0.2, -0.75,0)
- end
- function onThrow()
- if thrown == true then return end
- thrown = true
- local character = Tool.Parent
- local humanoid = character.Humanoid
- if humanoid == nil then return end
- local targetPos = humanoid.TargetPoint
- lob(targetPos)
- wait(5)
- thrown = false
- end
- function onEquipped()
- Weld(Tool)
- end
- function onUnequipped()
- Weld(Tool)
- end
- thrown = false
- Tool.Equipped:connect(onEquipped)
- Tool.Unequipped:connect(onUnequipped)
- Tool.Activated:connect(onThrow)
- Weld(Tool)]]
- local Nadescript = Instance.new("Script",tool)Nadescript.Name = "Nadescript"
- Nadescript.Source = [[flash = Instance.new("Part")
- flash.formFactor = "Symmetric"
- flash.Size = Vector3.new(1, 1, 1)
- flash.BrickColor = BrickColor.new(26)
- flash.Reflectance = 0.1
- flash.Anchored = true
- flash.Name = "Dot"
- flash.CanCollide = false
- mesh = Instance.new("SpecialMesh")
- mesh.Parent = flash
- mesh.MeshType = "Sphere"
- mesh.Scale = Vector3.new(0.5, 0.5, 0.5)
- for i=1, 50 do
- wait(0.1)
- local dot = flash:clone()
- local Script2 = script.DotScript:clone()
- Script2.Disabled = false
- Script2.Parent = dot
- dot.Parent = game.Workspace
- dot.Position = script.Parent.Position
- end
- local exp = Instance.new("Explosion")
- exp.Position = script.Parent.Position
- exp.Parent = game.Workspace
- script.Parent.Parent:remove()]]
- local Dotscript = Instance.new(script,Nadescript)Dotscript.Name = "Dotscript"
- Dotscript.Source = [[ script.Parent.Transparency = script.Parent.Transparency + 0.1
- wait(0.2)
- end
- script.Parent:remove()
- ]]
- local handle = Instance.new("Part",tool)tool.part.Name = ("Handle")handle.Brickcolor = BrickColor.new("Lime Green")
- Instance.new("Fire",handle) handle.Fire.Enabled = false
- Instance.new("TouchInterest", handle)
- Instance.new("Mesh",handle) handle.Mesh.Meshtype = ("Brick")handle.mesh.scale = Vector3.new (0.5, 1.0, 0.5)
- local handle1 = Instance.new("Part",tool)handle1.Name = ("Handle1")
- Instance.new("CylinderMesh",handle1)handle1.Mesh.scale = Vector3.new (0.5, 0.1, 1)
- Instance.new("Fire",handle1) handle1.Fire.Enabled = false
- local handle2 = Instance.new("Part",tool)handle2.Name = ("Handle2")
- Instance.new("CylinderMesh",handle2)handle2.Mesh = Vector3.new (0.3, 0.4, 1)
- local handle3 = Instance.new("Part",tool)handle3.Name = ("Handle3")
- Instance.new("SpecialMesh",handle3) handle3.Mesh.MeshType = ("Filemesh") handle3.Mesh.Meshid = ("http://www.roblox.com/asset/?id=3270017") handle3.Mesh.Scale = Vector3.new(0.2, 0.2, 0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement