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

How to make when you touch a part that you hear a sound?

Asked by 6 years ago
Edited 6 years ago

I tried putting everywhere the sound ID and even as parent, i want to make when you touch a Part that you can hear a sound, idk where to put the sound id or something... This is the script i wrote and i am having trouble fixing.

script.Parent.Touched:connect(function(hit) script.Parent.Sound:Play() end)

If someone helps me, i will be so thankful! :D

0
There’s a property in the sound called SoundId. Paste your ID there and make sure you have “rbxassetid://“ before it. User#20279 0 — 6y
0
I fell so dumb right now, thanks guys! :D D3LETED_DATA 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
script.Parent.Touched:connect(function(hit)
script.Parent.Sound:Play()
end)

If your script looks something like that it should work, and I do not see why it wouldn't unless it is an issue with the sound value, nothing hitting the part, etc. But I do believe the scripting looks ok.

0
Still not working ;( D3LETED_DATA 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Since I do not know if you want the sound played to be local, I will assume so. You want to put the object "Sound" inside of StarterGui, so it gets auto moved to PlayerGui when the player joins.

This is what I use, but with a few other thing, which is not nessesary for it work.

Local brick = (put the brick that you want to be touched in here)

brick.Touched:connect(function(hit)

 If hit.Parent:FindFirstChild("Humanoid") then

     local A =   Game.Players[hit.Parent.Name]:FindFirstChild("PlayerGui")

           If A then

              A.Sound:Play()

            end

end

end)

Unless I made a type, it should work.

Be sure to change the sound play the music you want.

Answer this question