function OnTouched(hit) script.Parent.WhatEverTheMusicIsNamed:Play() end wait (1) script.Parent.Touched:connect(onTouched)
COMMUNITY QUESTION
How do i make something play music on touch?
1 answer
If you mean as in click, then do this. Get any object and put it in a model with a ClickDetector. Then put Sound and a Script inside the object. Name the Sound, "Music". Then put this inside the script.
local isOn = false
function on()
isOn = true
script.Parent.Music:Stop()
end
function off()
isOn = false
script.Parent.Music:Play()
end
function onClicked()
if isOn == true then off() else on() end
end
script.Parent.Parent.ClickDetector.MouseClick:connect(onClicked)
on()
all good to go.
-- ur welcom
This discussion is preserved as it was. New answers, comments, and votes are closed.
