hi, im trying to make water which kills you and i need it to play a sound effect when it's touched.
this is the script i came up with:
function onTouch(part) script.Parent:Play() end
thanks in advance, from poopypigeon245
function onTouch (part) script.Parent:Play() end script.Parent.Touched:connect(onTouch)
Well, the function is not connected. You can try the following:
local CanPlay = true -- To prevent the song from playing multiple times. local CanKill = true function Play(hit) local Song = workspace.YourSong if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then -- We check for a humanoid and if the hit's parent is a Model. if CanPlay and CanKill then -- If CanPlay and CanKill are true. hit.Parent:BreakJoints() -- We kill the Character. CanPlay = false CanKill = false -- We set both variables to false. Song:Play() -- We play the song. wait(5) -- 5 Second delay. CanPlay = true CanKill = true -- We set both variables to true. end end end script.Parent.Touched:connect(Play) -- In my case, I parent the script to the Part.
Hope that helped. (Sorry for any mistakes, grammar mistakes or bad explanation.)
-AlessandroG200