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

How do I make it so the game plays a sound when the player clicks while an item is being held?

Asked by 4 years ago

Just for some context: "GameToy" is the tool that should be equipped when the player clicks, and plays the sound. And "sound" is the sound that's supposed to play. And "Backup" is the sound that was meant to play, and backup is the folder in the workspace that has the tool.

Here was my previous attempt:

local tool = Workspace.Backup.GameToy
local sound = game.workspace.backup.GameToy.Sound
tool.Activated:Connect():Button2Down():Connect(function()
  game.Workspace.Backup.GameToy.Sound:Play()
end)

1 answer

Log in to vote
0
Answered by
Subsz 366 Moderation Voter
4 years ago

You're on the right track, but you're still wrong.

So first, make a local script inside the tool.

and then use tool.Activated for that. an example would be :

local tool = script.Parent
local sound = workspace.Sound

tool.Activated:Connect(function()
sound:Play()
end)
Ad

Answer this question