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

how can i make a sound play when a part touches another part?

Asked by
omorizz 50
2 years ago

when a part is pushed onto a different part then a sound plays once, how can i script this?? (am a noob at scripting)

0
check the new scirpt Xapelize 2658 — 2y

1 answer

Log in to vote
2
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago
local AnotherPart = workspace.AnotherPart
local Sound = game.Workspace.Sound

local Debounce = false

local COOLDOWN = 5

script.Parent.Touched:Connect(function(hit)
    if hit == AnotherPart and not Debounce then
        Debounce = true
        Sound:Play()
        task.wait(COOLDOWN)
        Debounce = false
    end
end)

AnotherPart will be the part where it will play the sound when touched the script.Parent brick.

Be sure to locate the AnotherPart and the Sound to where they are in the game

COOLDOWN is the cooldown value so it makes the sound playing have cooldown

Last thing is put this script inside the brick

Ad

Answer this question