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

How do I make sound play in a part when the object is hitting or bouncing on something?

Asked by 6 years ago

Hello, Just wondering how to make a sound plays inside a part, when the part for itself is hitting or bouncing on the ground, walls, other parts ... For example: When I throw a bottle inside a game, I want the soundFX inside it play when the bottle hit something (Table, Wall, Ground...) Basically when hit everything. How to do that? Thanks for help, please I need it as soon as possible.

1 answer

Log in to vote
0
Answered by 6 years ago

Just for your information, this is not a demand site - don't just ask for stuff to be made. Please consider this next time. But I'll help you:

Place a script inside the bottle or whatever object you want the sound to play.

local object = script.Parent --you can edit this to wherever you object is located

s.Touched:connect(function(hit)
    if hit.Name == "Part" then --if whatever the object hits is named Part 
        local sound = Instance.new("Sound") --creates a new sound object
        sound.Parent = object --sound will be in the object
        sound.SoundId = 0 --put your soundId here
        sound.MaxDistance = 10 --put your MaxDistance here
end)

Please accept this as an answer if you found this helpful.

Ad

Answer this question