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

Need help with Bodypositions and A constantly Activated script?

Asked by 9 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()
    wait()
    Tool.Handle.BodyPosition.position = Tool.Parent.Torso.Position + Vector3.new(20,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
end

Tool.Equipped:connect(onActivated)

1 answer

Log in to vote
2
Answered by
xPolarium 1388 Moderation Voter
9 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

0
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 — 9y
Ad

Answer this question