I want to know how to make a part make a sound when it hits something

so basically for example, when I drop a rock and hits the floor it makes a rock noise How would I go about doing this? Do I use (: onTouch) how will it know to stop playing? pls help

4 Likes

To achieve your goal, you have to create a script inside your rock.
Afterwards, insert this code into the script.
You will then need to insert the audio aka the rock noise into your rock.

local Audio = script.Parent.Sound -- the audio you want to play
local part = script.Parent -- the part that will collide with the floor
local db = false -- debounce so that the audio does not repeat itself over and over again

local function onPartTouched(otherPart)
	if not db then
		db = true
		Audio:Play()
		wait(30) -- time until the audio can restart
		db = false
	end
	
end
 
part.Touched:Connect(onPartTouched)

Hope this helps you.

5 Likes

is it possible to make 2 sounds play per hit? technically after the first sound, another one plays.

2 Likes