Still have questions? Join our Discord server and get real time help.
Log in to vote

Need help with Bodypositions and A constantly Activated script?

Asked by 4 years ago

So lately I've been trying to script a Boomerang using a BodyPosition to make it go a distance away from the player. I have 2 problems. 1st off I have made the position for the body position add 20 studs away from the player on the X axis. I need it to go 20 studs in front of the player. I tired this with Lookvector but had no luck. My second problem is that the Tool seems to be activated 100% of the time rather then just on a click. So as soon as I pick the tool up it just goes to it's BodyPosition's Position without me activating it. I tried Explaining best as I can but it might be a bit hard to understand.

Tool = script.Parent

function onActivated()
    Tool.Handle.BodyPosition.position = Tool.Parent.Torso.Position +,0,0) --This is where I don't know how to make the Position go 20 studs in front of the player rather than just 20 studs on the X axis.
    Tool.Parent = game.Workspace


1 answer

Log in to vote
Answered by
xPolarium 1358 Moderation Voter
4 years ago

The reason why your tool script is being executed is because you are using the Equipped() event. This event fires when you equip the tool by pressing it's key bind.

If you want it to fire when you click (Like all weapons do) then change Tool.Equipped:connect(onActivated) to Tool.Activated:connect(onActivated). The Activated() event would fire when a play clicks while the tool is equipped. This should answer your problem of the script being activated 100% of the time.

More on tool events here

Okay I understand thanks! Also I figured out how to use look vector for this but it is still buggy so I will ask about that later minikitkat 687 — 4y

Answer this question