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

How do you detect you're character in workspace?

Asked by 2 years ago

Im a little new to scripting, Im making an explode button that if you press it, it will play a sound that is inside you're character and can be also heard by other players and i don't know how to detect your character. Please help Thx

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You can use a ClickDectector.

Insert a ClickDetector inside of the part to press.

And insert a script inside of the part.

Use the MouseClick event for the ClickDetector (Once clicked by mouse, the event fires).

It also returns the player object so you can do

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local sound = Instance.new('Sound', player.Character) 
    sound.SoundId = Sound id here
    sound:Play()
    print("Sound is played inside of "..player.Name.."'s character!")
end)
Ad

Answer this question