Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local playerGUI = player:WaitForChild('PlayerGui')
- local Mouse = player:GetMouse()
- local RS = game:GetService("RunService")
- local Debris = game:GetService("Debris")
- local Handle = script.Parent.Handle
- local Ammo = player.BowAmmo
- local MaxAmmo = 20
- local reloading = false
- local debounce = true
- local FireAnimation = script.Parent:WaitForChild("Fire")
- local IdleAnimation = script.Parent:WaitForChild("Idle")
- local LoadAnimation = script.Parent:WaitForChild("Load")
- playerGUI.AmmoGUI.BG.Visible = true
- local character = player.Character or player.CharacterAdded:Wait()
- local Hum = character:WaitForChild("Humanoid")
- local IdleTrack = Hum:LoadAnimation(IdleAnimation)
- local LoadTrack = Hum:LoadAnimation(LoadAnimation)
- script.Parent.Equipped:Connect(function()
- playerGUI.AmmoGUI.BG.Visible = true
- IdleTrack:Play()
- end)
- script.Parent.Unequipped:Connect(function()
- playerGUI.AmmoGUI.BG.Visible = false
- IdleTrack:Stop()
- end)
- script.Parent.Activated:Connect(function()
- -- animation again
- if debounce == true then
- debounce = false
- local Fire = script.Parent.Fire
- local Idle = script.Parent.Idle
- local char = player.Character
- local Hum = char.Humanoid
- local Track = Hum:LoadAnimation(Fire)
- LoadTrack:Play()
- LoadTrack.Stopped:Wait()
- Track:Play()
- if Ammo.Value > 0 then
- Ammo.Value = Ammo.Value -1
- local flying = false
- -- mouse Vars
- local Target = Mouse.Hit
- local Arrow = game.ReplicatedStorage.Arrow:Clone()
- local HandlePosition = Handle.Position
- local HandleOrientation = Handle.CFrame.UpVector * 2
- Arrow.CFrame = CFrame.lookAt(HandlePosition,Target.Position)*CFrame.Angles(0,math.rad(180),0)
- Arrow.BodyVelocity.Velocity = -Arrow.CFrame.LookVector * 200
- Arrow.Parent = game.Workspace
- flying = true
- local Touched = false
- Arrow.Touched:Connect(function(hit)
- if hit.Name == 'Bow' then return end
- if hit.Name == 'Handle' then return end
- if hit.Parent == player.Character then return end
- if hit.Name == 'Arrow' then return end
- Arrow.Trail.Transparency = NumberSequence.new(1)
- Arrow.Anchored = true
- if hit.Parent:FindFirstChild("Humanoid") then
- if Touched == false then
- Touched = true
- hit.Parent:FindFirstChild("Humanoid"):TakeDamage(75)
- end
- end
- end)
- RS.RenderStepped:Connect(function()
- if flying == true then
- if Arrow:FindFirstChild("BodyVelocity") then
- Arrow.BodyVelocity.Velocity = Arrow.BodyVelocity.Velocity - Vector3.new(0,1,0)
- end
- end
- wait(2)
- end)
- Debris:AddItem(Arrow, 15)
- end
- wait(2)
- debounce = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement