I want the player to hear a button click when they click the button, is there a way how?
the title and description ask 2 different questions
to get the head of the player who clicked a button, you would put this in a local script:
Script.Parent.MouseButton1Click:Connect(function() -- button location here
local plr = game.Players.LocalPlayer
local plrChar = plr.Character
local head = plrChar:WaitForChild("Head")
-- do whatever you want with the head here
end)
to play a click sound or any sound, simply insert the sound you want to play into StarterGui and put this in a local script:
ButtonLocation.MouseButton1Click:Connect(function() -- replace ButtonLocation with the location of the button, preferably in the button
local plr = game.Players.LocalPlayer
plr:WaitForChild("PlayerGui"):WaitForChild("SoundNameHere"):Play()
end)
Ty!! I only needed the first script! Have a good day : D
Um I have a little misfunction. Does the first script work for you?
replace the “ButtonLocation” to where the button is located.
what i would do is put the script in the button and do
Script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local plrChar = plr.Character
local head = plrChar:WaitForChild("Head")
-- do whatever you want with the head here
end)
so place the local script inside of the button and replace the script with this, also make sure that the script is a LocalScript
My bad, I forgot it had to be a local script
sorry, it should be:
Script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local plrChar = plr.Character
local head = plrChar:WaitForChild("Head")
-- do whatever you want with the head here
end)
a little tired rn lol
I am so sorry! But it worked!! Tysm :DDD