local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
local hit = mouse.Hit
local arrow = game.ReplicatedStorage.Arrow:Clone()
local velocity = Instance.new('BodyVelocity', arrow)
arrow.Parent = workspace
arrow.CFrame = script.Parent.Handle.CFrame*CFrame.new(character.HumanoidRootPart.CFrame.lookVector*2)
arrow.CFrame = CFrame.new(arrow.Position, hit.p)
arrow.BodyVelocity.velocity = arrow.CFrame.lookVector*320
arrow.Touched:Connect(function(touch)
if touch.Name == 'Handle' then return end
if touch.Parent == player.Character then return end
arrow:Destroy()
end)
end)
Just wanting to get basic thoughts?? Ways I could improve what I’ve currently got. How it would be affected by FE (FE box is ticked, and seems to work when I test, but just worried about in the future when it comes time to doing damage to players, etc.)
Also want to know if BodyVelocity is the best way to go about this? As it works nice and easily, but I’d like to eventually implement a natural drop (like how a normal arrow would work) and not just have the arrow fly completely across the map without any gravity effect.
If this is in a local script, change it to a server script. You can get the player from the character whenever it’s equipped for the first time.
If it’s a local script, only the player who shoots it will see the arrow.
You would use a local script to get input and a server script to check when a remote inside the tool is fired with the mouse position, and handle shooting from there.
This won’t work with FE. Oof. It will only work for the client using the bow.
I personally just avoided moving my arrow at all and just moved it directly where the user clicked to avoid any weird errors. You might want to try this.
Basically you’d calculate where the arrow ought be using something like renderstepped or something and ray cast infront of the arrow to find the target.
For replication you’d immidiently show the arrow moving on the client and shoot to the server for security checks and replication to other clients.
I included a little experiment I did while I was in high school physics that should set you on the right track. Its just calculating where a projectile should be given several variables.
If you press run (Just do run server not play solo) you’ll see the path of path projected from that part floating in the air based on a simple physics equation and a given velocity. It then shoots a part at the velocity to show the actual path.
And you wouldn’t need body velocity because you should be updating the CFrame value all the time.
Hey guys Im new on this soo can you explain me how to make the bow with the arrow ( i made the bow in blender soo, but i dont know a lot of making script things.