Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What concepts do I need to understand in order to make a bow?

Hello again! So I have been trying to code a bow and I've ran into some troubles. I just don't know how and there aren't any tutorials telling me how to do stuff like this. I don't know enough Lua to make a bow so I was wondering if any of you guys could help me understand some concepts that could get me there. I have already made my bow and arrow I just need to put it into action. All help is appreciated. Here is my current code:

local bow = script.Parent
local storage = game:GetService("ReplicatedStorage") --To get the arrow out of storage
bow.Activated:Connect(function(mouse)
	local chrac = bow.Parent
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
	local mouse = player:GetMouse()
	local head = game.Workspace[player.Name].Head.CFrame.lookVector
end)

Thanks in advance!

1 answer

✓ Accepted answer

If you wanted to make it shoot like a realistic bow, just know that acceleration due to gravity is 9.8 m/s^2 [downwards] and horizontal velocity is constant.

Make an arrow and then spawn it in the bow (or wherever), then use the information I wrote above.

To make the arrow damage, use the BasePart:GetTouchingParts() function or use the BasePart.Touched event.

2 comments

0

How would I apply force the arrow, and how would I know where the mouse is?

0

You can set the velocity of the arrow when it spawns in, or you can use a bodymover such as bodyforce or bodyvelocity. To get the mouse, you need to use a local script. Here's what you need (I think): https://developer.roblox.com/en-us/api-reference/property/Mouse/Hit

This discussion is preserved as it was. New answers, comments, and votes are closed.