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.
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.
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
thank you
No problem. Make sure to accept my answer.