Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- parts = script.Parent; --Parts Model For The Tank
- ignoreList = {script.Parent}; --Table Which The Rays Will Ignore
- radius = 10; --Kill Radius For HE Rounds (2*Radius Is Hurt Zone)
- dealingdamage = 200
- makeRays = false;
- --Remove Old Rays
- if workspace:findFirstChild("Rays") then
- workspace:findFirstChild("Rays"):remove();
- end
- --Make New Model For Rays If Enabled
- if makeRays then
- m = Instance.new("Model");
- m.Name = "Rays";
- m.Parent = workspace;
- end
- --Function For Making New Ray Bricks
- function makeRay(cframe, size)
- local p = Instance.new("Part")
- p.Name = "RayPart"
- p.BrickColor = BrickColor.new("Bright red")
- p.Transparency = 0.5
- p.Anchored = true
- p.CanCollide = false
- p.TopSurface = Enum.SurfaceType.Smooth
- p.BottomSurface = Enum.SurfaceType.Smooth
- p.formFactor = Enum.FormFactor.Custom
- p.CFrame = cframe
- p.Size = size
- p.Parent = m
- ignoreList[#ignoreList+1] = p
- end
- local flash = parts.Parent.Gun.Muzzle:clone()
- flash.Parent = game.Workspace
- flash.Anchored = true
- parts.Parent.Gun.Muzzle.Sound:Play();
- local FL = flash.PointLight:clone()
- FL.Parent = flash
- FL.Enabled = true
- local Flashy = flash.Flash:clone()
- Flashy.Parent = flash
- Flashy.Enabled = true
- game.Debris:AddItem(FL, .07)
- game.Debris:AddItem(Flashy, 2)
- game.Debris:AddItem(flash, .08)
- round = Instance.new("Part", user)
- round.Name = "RayPart"
- round.Transparency = 0
- round.Anchored = true
- round.CanCollide = true
- round.TopSurface = Enum.SurfaceType.Smooth
- round.BottomSurface = Enum.SurfaceType.Smooth
- round.Material = Enum.Material.Neon
- round.formFactor = Enum.FormFactor.Custom
- round.BrickColor = BrickColor.new("Daisy orange")
- yOffset = -0.2
- local PL = Instance.new("PointLight")
- PL.Parent = round
- PL.Brightness = 50
- PL.Color = Color3.new(255, 255, 0)
- PL.Range = 10
- PL.Shadows = true
- --Offset For Each New Ray For The Bullet's Trajectory
- local offset = (parts.Parent.Gun.Muzzle.CFrame*CFrame.new(math.random(-5,5)/3,100,math.random(-5,5)/3).p
- - parts.Parent.Gun.Muzzle.Position).unit
- *script.Parent.Stats.GunVelocity.Value
- local point1 = parts.Parent.Gun.Muzzle.Position
- --Loop For Making Rays For The Bullet's Trajectory
- for i = 1, 30 do
- local thisOffset = offset + Vector3.new(0, yOffset*(i-1), 0)
- local travelRay = Ray.new(point1,thisOffset)
- local hit, position = workspace:FindPartOnRay(travelRay, parts.Parent)
- local distance = (position - point1).magnitude
- round.Size = Vector3.new(.6, distance, .6)
- round.CFrame = CFrame.new(position, point1)
- * CFrame.new(0, 0, -distance/2)
- * CFrame.Angles(math.rad(90),0,0)
- round.Parent = workspace
- point1 = point1 + thisOffset
- if hit then
- round:remove()
- local e = Instance.new("Explosion")
- e.BlastRadius = 5
- e.BlastPressure = 0
- e.Position = position
- e.Parent = workspace
- e.DestroyJointRadiusPercent = 0
- script.Parent.Touched:Connect(function(hit)
- local HitSound = hit.Parent:FindFirstChild("Pen"):Clone()
- local DoesFrontArmor = hit.Parent:FindFirstChild("FrontArmor")
- if hit.Parent:FindFirstChildOfClass("Model") and not DoesFrontArmor then
- hit.Parent.Parent:FindFirstChild ("Damage").Value = -5
- elseif DoesFrontArmor then
- hit.Parent.Parent:FindFirstChild ("Damage").Value = hit.Parent.Parent:FindFirstChild ("Damage").Value - dealingdamage /2
- end
- end)
- local players = game.Players:getChildren()
- for i = 1, #players do
- if players[i].TeamColor ~= script.Parent.Parent.Tank.Value then --if he's not an ally
- character = players[i].Character
- torso = character:findFirstChild'Torso'
- if character and torso then
- torsoPos = torso.Position
- origPos = round.Position
- local ray = Ray.new(origPos, torsoPos-origPos)
- local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignoreList)
- if hit then
- if hit.Parent == character then
- human = hit.Parent:findFirstChild("Humanoid")
- human2 = hit.Parent.Parent:findFirstChild("Humanoid")
- if human then
- distance = (position-origPos).magnitude
- print("Distance from "..character.Name.." = "..distance)
- if distance <= 2*radius then
- torso.Velocity = (torso.Position - position).unit * 100;
- human:takeDamage(100-(distance-radius)*(100/radius))
- -- If player died
- if human.Health <= 0 then
- torso.Velocity = (torso.Position - position).unit * 10;
- print("Dead");
- end
- print("Took "..(100-(distance-radius)*(100/radius)).." Damage")
- end
- elseif human2 then
- distance = (position-origPos).magnitude
- print("Distance from "..character.Name.." = "..distance)
- if distance <= 2*radius then
- torso.Velocity = (torso.Position - position).unit * 100;
- human:takeDamage(100-(distance-radius)*(100/radius))
- -- If player died
- -- if human.Health <= 0 then
- torso.Velocity = (torso.Position - position).unit * 10;
- print("Dead");
- end
- print("Took "..(100-(distance-radius)*(100/radius)).." Damage")
- end
- end
- else print("Didn't hit Target")
- end
- if makeRays then
- makeRay(CFrame.new(origPos, position)
- * CFrame.new(0, 0, -distance/2), Vector3.new(0.2, 0.2, distance))
- end
- end
- end
- end
- round:remove()
- break
- end
- wait()
- end
- if round then
- round:remove()
- end
- script:remove()
Advertisement
Add Comment
Please, Sign In to add comment