Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local head = script.Parent
- local Body_Position = head.BodyPosition
- local StudsAway =20
- Body_Position.Position = head.CFrame.p
- radius = script.Parent.Parent.radius
- cooldown = 3 -- Cooldown
- cooldown2 = cooldown / 2
- cd = cooldown - cooldown2
- script.Parent.Parent.radius.Size = Vector3.new(0.1,StudsAway,StudsAway)
- script.Parent.Parent.radius.Size = script.Parent.Parent.radius.Size + script.Parent.Parent.radius.Size
- while wait() do
- zombie = game.workspace.Zombies:FindFirstChild("Zombie") --Find Enemy
- if zombie ~= nil then
- health = zombie.Health.Value
- local hitzone = zombie.green.Position - Vector3.new(zombie.green.Position.X,0,0)
- local distance = (head.CFrame.p - zombie.green.CFrame.p).Magnitude
- if distance <= StudsAway then
- --Attack Enemy
- script.Parent.Parent.PrimaryPart = head
- script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(head.CFrame.p, zombie.hit.CFrame.p))
- script.Parent.Parent:SetPrimaryPartCFrame(CFrame.Angles(0, script.Parent.Parent.PrimaryPart.Orientation.Y/180*math.pi, script.Parent.Parent.PrimaryPart.Orientation.Z/180*math.pi) + script.Parent.Parent.PrimaryPart.Position)
- -----------------------
- local parts = radius:GetTouchingParts()
- table.insert(parts,2,"hi")
- -----------------------
- health = health - 3 --damage
- zombie.Health.Value = health
- script.Parent.Parent.Gunfire.Transparency = 0.2
- wait(cooldown2)
- script.Parent.Parent.Gunfire.Transparency = 1
- wait(cd)
- end
- else
- --script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(head.CFrame.p, script.Parent.Look.CFrame.p))
- script.Parent.Parent:SetPrimaryPartCFrame(CFrame.Angles(0, script.Parent.Parent.PrimaryPart.Orientation.Y/180*math.pi, script.Parent.Parent.PrimaryPart.Orientation.Z/180*math.pi) + script.Parent.Parent.PrimaryPart.Position)
- wait()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement