Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Text Button plays no sound when clicked?

I am trying to play a sound when a Text Button is clicked

game.StarterGui.ScreenGui.Frame.bassattackbutton.Activated:Connect(function()
game.Workspace.bassattack:Play()
end)

The output doesnt put out any error nor does the sound play.

1 answer

First of all, you need to get the button that is in the player's PlayerGui, not the StarterGui.

Also a TextButton has a MouseButton1Click event you can use to detect when the button is clicked.

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Button = PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("bassattackbutton")

Button.MouseButton1Click:Connect(function()
	game.Workspace.bassattack:Play()
end)

2 comments

0

thank you

0

No problem. Make sure to accept my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.