Hello!
I can't get my script to work, so I need help. What I really want is for people to click on an item and the music starts playing for like 10 seconds. After that it will automatically stop until clicked again. It will be even more ideal if only the person who clicks the item will hear the music!
So far, I have two scripts and I don't know how to combine the two for it to work. So please, please someone smart out there help me with my script!
What I do now (for example) is create a brick, insert "sound" (that I looked up in my toolbox) add a script into my brick with the following code:
script.Parent.Touched:connect(function(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
if plr then
script.Parent.Sound:Play()
end
end)
This will work if you walk over the brick, but it is not what I want. So I tried to insert a ClickDetector (right click on my brick and add the ClickDetector) Add a script with the following code:
function onClicked(playerWhoClicked)
script.Parent.BrickColor = BrickColor.Random()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
However this will not work. I think the problem is they need to be combined, but I never done scripting so I don't know how to do it. The sound script (the first one) also doesn't stop the music after 10 seconds. And of course there is still the issue with the one who clicks the sign/brick only hears the audio.
I know this is probably not easy, but I'm just trying my luck here on this forum.
If you have any suggestions, please write them down. It is very much appreciated.

1 comment
The MouseClick function returns the player, not what.... "Hit"?