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

How to make an audio play when tool is activated, but stop once I click again?

Asked by 8 years ago
Tool = script.Parent
function onActivated()
    Tool.Bape.Stark:Play()
    wait(0.1)
    Tool.Bape.Stark:Stop()
end

I know it's not much to work with, but I'm kinda at a loss right now. Sorry in advance.

1 answer

Log in to vote
0
Answered by
StoIid 364 Moderation Voter
8 years ago
Edited 8 years ago

You're almost there!

To detect when a player does a Left-Click with tools, we can "listen" for it with the tool.Activated event! This event fires every time a player Left-Clicks with the tool equipped.

In your code, this would be...

Tool.Activated

Also just a little extra, I like to construct my listening events like this, but you can keep it your way.

Tool.Activated:Connect(function()
    -- Stuff Here!
end)

Either way is fine, this is just my preferred way. You can try it out for yourself too!

Any problems? Just comment below!

Ad

Answer this question