I scripted a bow and arrow, but for some reason the projectile becomes anchored in mid air. Here’s my script:
(“arrowClone” is just an unanchored, ball-shaped part. “position” is the position of where the arrow should start, “force” is the force applied to move the ball, “upForce” is a force applied to reduce gravity on the part so it takes more time to fall)
fireArrowEvent.OnServerEvent:Connect(function(plr, position, force, upForce)
local arrow = arrowClone:Clone()
arrow.Position = position
arrow.Parent = workspace
arrow:SetNetworkOwner(nil)
local bf = Instance.new("BodyForce", arrow)
bf.Force = Vector3.new(0, upForce * arrow.AssemblyMass,0)
arrow:ApplyImpulse(force * arrow.AssemblyMass)
local connection
connection = arrow.Touched:Connect(function(hit)
if hit.Parent ~= plr.Character and hit.Parent.Parent ~= plr.Character then
print("Hit", hit.Name)
arrow.Anchored = true
connection:Disconnect()
end
end)
end)
As shown in the video below, the output prints that the arrow hit the object. For some reason the game thinks that the arrow has touched the part, while to the player it looks like it’s still in midair. Also when I used the exact same code but spawned the arrow from the client, it worked fine, so the issue has to do with the server.
Any ideas on what could be the problem?
Edit: I tried setting the network ownership to the player who fired it. It looked right from the player’s end, but to the server it still looked like it stopped in mid air.