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

Text Button plays no sound when clicked?

Asked by
8muq 2
3 years ago

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

Log in to vote
0
Answered by 3 years ago

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)
0
thank you 8muq 2 — 3y
0
No problem. Make sure to accept my answer. xInfinityBear 1777 — 3y
Ad

Answer this question