How to insert sound on humanoid when clicked on Gui?

Hello devs, i just made an Screen GUI, and the function that i want to do is play a sound on humanoid when you click on the GUI.

How i can do that?

Any script will be Helpful!

1 Like

Hi, Add this local script into a button Inside of the local script add the sound

local sound = script.Sound
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
local soundclone = sound:Clone()
soundclone.Parent = Player.Character.Humanoid
soundclone:Play()
end)
1 Like

I mean I don’t rlly want to give you a free bee on this one because you wouldn’t be learning much. But I hope you can learn from it.
(Put this in a local script)

local Button = script.Parent --- Your Button
local plr = game.Players.LocalPlayer --- The Client

Button.MouseButton1Click:Connect(function() --- Fires when a plr clicks the button
local Sound = game.replicatedstorage.Sounds.Audio:Clone() --- Change this to the sound
local char =  plr.Character --- Defines the character
sound.Parent = char:FindFirstChild("Humanoid") --- Parents the Audio to the humanoid
sound:Play() --- Plays the sound.
end) --- Closes the function.


The local script will make only me hear the sound?

1 Like

Yeah it will make you only hear the sound because local script = client (your computer/device)