Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local Mouse = Player:GetMouse()
- repeat wait() until Player.Character
- local MyCharacter = Player.Character
- local Head = MyCharacter:WaitForChild('Head')
- local Template = Head:Clone()
- local Enabled = false
- local CoolDown = 2
- local LastAttack = tick()
- local Mode = 1
- local Help = 'Controls: Q(true) - Enable/Disable, E - Change mode(1), Click - Fire, FocusLost - Target head'
- local ScreenGui = Instance.new('ScreenGui')
- local TextBox = Instance.new('TextBox', ScreenGui)
- TextBox.BackgroundTransparency = 0.5
- TextBox.BackgroundColor = BrickColor.Blue()
- TextBox.Size = UDim2.new(0.2, 0, 0.1, 0)
- TextBox.Position = UDim2.new(0.4, 0, 0, 0)
- TextBox.Font = Enum.Font.ArialBold
- TextBox.FontSize = Enum.FontSize.Size18
- TextBox.TextColor = BrickColor.White()
- TextBox.BorderSizePixel = 0
- TextBox.Text = Help
- TextBox.TextWrapped = true
- ScreenGui.Parent = Player.PlayerGui
- TextBox.FocusLost:connect(function(Enter)
- if Enter then
- local PlayerName = TextBox.Text
- local Character = workspace:FindFirstChild(PlayerName)
- if Character then
- local Found = Character:FindFirstChild('Head')
- if Found then
- Template = Found:Clone()
- else
- Template = Head:Clone()
- end
- end
- TextBox.Text = Help
- end
- end)
- Mouse.KeyDown:connect(function(Key)
- if Key == 'q' then
- Enabled = not Enabled
- local str = string.gsub(Help, '%(%a+%)', '(' .. tostring(Enabled) .. ')')
- TextBox.Text = str
- elseif Key == 'e' then
- Mode = Mode == 1 and 2 or 1
- local str = string.gsub(Help, '%d', Mode)
- TextBox.Text = str
- end
- Help = TextBox.Text
- end)
- Mouse.Button1Down:connect(function()
- if not Enabled then return end
- if tick() - LastAttack < CoolDown then return end
- LastAttack = tick()
- local Hit = Mouse.Hit
- local HeadPosition = Head.Position
- local Offset = Hit.p - HeadPosition
- local Direction = Offset.unit
- local SpawnPosition = HeadPosition + (5 * Direction)
- local Projectile = Template:Clone()
- local function onTouched(Hit)
- if Hit:IsDescendantOf(MyCharacter) then return end
- local Explosion = Instance.new('Explosion', workspace)
- Explosion.BlastRadius = 20
- Explosion.BlastPressure = 7E5
- Explosion.Position = Projectile.Position
- Projectile:Destroy()
- end
- local function attack(mode, object)
- if mode == 1 then
- object.Parent = workspace
- object.CFrame = CFrame.new(SpawnPosition, Hit.p)
- object:BreakJoints()
- object.Velocity = 300 * Direction
- game.Debris:AddItem(object, 5)
- elseif mode == 2 then
- local Expire = 20
- local Target
- local function FindNearestHead()
- local Distance = 70
- local Closest
- for Index, Instance in next, workspace:GetChildren() do
- if Instance:IsA('Model') then
- local Humanoid = Instance:FindFirstChild('Humanoid')
- if Humanoid then
- local Located = Instance:FindFirstChild('Head')
- if Located and Located ~= Head then
- local Offset = Located.Position - Head.Position
- if Offset.magnitude < Distance then
- Distance = Offset.magnitude
- Closest = Located
- end
- end
- end
- end
- end
- return Closest
- end
- game.Debris:AddItem(object, Expire)
- object.Parent = workspace
- object.CanCollide = false
- object.Anchored = true
- object:BreakJoints()
- for Value = 1, Expire * 30 do
- wait()
- object.CFrame = Head.CFrame * CFrame.new(5 * math.sin(math.rad(Value)), 0, 5 * math.cos(math.rad(Value)))
- Target = FindNearestHead()
- if Target then
- break
- end
- end
- if Target then
- object.Anchored = false
- object.Velocity = 700 * (Target.Position - Head.Position).unit
- end
- end
- end
- Projectile.Name = 'Explosive'
- Projectile.Touched:connect(onTouched)
- attack(Mode, Projectile)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement