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

How do I locally play a sound through a surface GUI?

Asked by 8 years ago

I want to locally play music through clicking a TextButton on a surface GUI. The sound would only play for the player who clicked.

1 answer

Log in to vote
0
Answered by 8 years ago

First, you should probably make sure the sound is in the player. You can do this by copying the sound and placing it into the local player. There are other ways, but I found this most simple. Next, just play the sound using a local script. That's all you have to do really. Here's some example code below,

--- Make sure this is in a local script
local player = game.Players.LocalPlayer--Can only do this with a local script
local sound = game.ServerStorage:WaitForChild("Sound") -- define the sound 
local SoundCopy = sound:Clone() -- clone the sound
SoundCopy.Parent = player -- put it in the local player
SoundCopy:Play() -- play the copy

Hope that helped! Good luck!

0
Where would you find the local player? FlashMint 5 — 8y
0
I updated my answer with an examples. Also, make sure to except the answer if it helped so we both get reputation.  User#11440 120 — 8y
Ad

Answer this question