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

How to make a tool know when it is used and how do you make a proper projectile?

Asked by
Smunkey 95
8 years ago

I have been trying to make a bow and arrow that works similar to the generic pew pew gun, where when you click a button it shoots a brick that deals damage on impact. Nothing overly complicated. However I have no idea how projectiles work as shown by the script below


local tool = script.Parent local player = game.Players.LocalPlayer local fired = tool.Activated --when the tool is used local bullet = game.Workspace.ReplicatedStorage.bullets.arrow --the bullet local damage = 1 --how much damage the bullet outputs local cooldown = 1 -- how long before you can fire again local distance = 15 --how long before the bullet dissapears function bullet:clone().Parent = tool tool.arrow.velocity = 150 end

This was the best I could come up with.

I know you need to have the script detect when the tool is clicked, have it spawn an item, give that item a velocity, then assign damage to that item.

So, how do you make it so a tool knows when it is clicked and how do you make a proper projectile with velocity and damage?

I'd prefer if answers contained minimal scripting but rather just the functions i need and how they work, because I want to make this myself.

1 answer

Log in to vote
1
Answered by 8 years ago

I would check out Friaza Hyuga tutorials, he made some for that topic.

Ad

Answer this question