Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Bow shooting script makes the bow shoot in one direction?

Asked by 7 years ago
Edited 7 years ago

Alright, so there's this script in a tool that I'm trying to make, and it's supposed to fire a bow projectile. It works, for the most part, but the thing is, it only fires in one direction. So like, whenever the player turns around, it still fires in one direction. (Ex. when the player turns and shoots the bow,it still fires forward while the player is backward) I want it to shoot arrows wherever the player is facing. How can I fix this to do so? I believe my error(s) mainly lie in lines 14-16.

Here is the code:

local player = game.Players.LocalPlayer
local char = player.Character
function GetBullet()
local p = script.Parent.Arrow:Clone()
p.Parent = game.Workspace
p.CanCollide = false
Instance.new("BodyVelocity",p)
return p
end

script.Parent.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
    local mH = mouse.Hit
    local bullet = GetBullet()
    bullet.CFrame = CFrame.new(script.Parent.Handle.Position+ script.Parent.Arrow.CFrame.lookVector*2)
    bullet.BodyVelocity.velocity = bullet.CFrame.lookVector * 1200
    bullet.Touched:connect(function(hit)
        local zombie = hit.Parent:FindFirstChild("Zombie")
        if zombie then
            zombie:TakeDamage(10)
        end
    end)
end)
end)
0
Read my bio. hiimgoodpack 2009 — 7y

Answer this question