So i am making a bow that shoots automatically. It kind of works, but there are few major problems with its movement.
-
I move the arrows with Z axis relative to their attachment. At the end it goes where i want to, but first it moves a bit right, then turns to the desired axis (see the video).
-
It lags amidst movement, stops for half a second and only then continues to move. My game doesnt lag, there arent even that many things in it to lag, and only these arrows movement lags.
-
With a script i am bending players torso to the mouse position. As you can see tool handle bends too (as intended). However the arrows still spawn with 0 orientation at the Y (x in my case cuz rotated) axis.
I would be much grateful if you would help me solve any or all of these problems. Here are the relevant scripts and hierarchy.
Script inside the tool.
local tool = script.Parent
local pl = tool.Parent.Parent
local char = pl.Character or pl.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local equipped = false
local arrow = workspace:WaitForChild("Arrow")
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
while task.wait(1) do
if equipped == true then
local newArrow = arrow:Clone()
newArrow.Parent = workspace
newArrow.Transparency = 0
newArrow.CFrame = tool.Handle.CFrame
newArrow.Anchored = false
newArrow.VectorForce.Enabled = true
--newArrow.Orientation = Vector3.new(0, newArrow.Orientation.Y , newArrow.Orientation.Z)
newArrow.Script.Disabled = false
end
end
script inside the arrow
local arrow = script.Parent
arrow.LinearVelocity.VectorVelocity = Vector3.new(0,0,-200)
arrow.Touched:Connect(function(hit)
if hit.Parent.Name == "NPCTest" then
hit.Parent:FindFirstChild("Humanoid").Health = 0
arrow:Destroy()
end
end)
task.wait(3)
arrow:Destroy()
Hierarchy (The arrow is directly under workspace)