generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Help with ontouch

Previous Thread :: Next Thread 
IciFlame is not online. IciFlame
Joined: 28 Sep 2013
Total Posts: 300
26 Jan 2016 06:41 PM
I want to make this part that when you touch it, it plays a sound. I already got that down.

But what do I need to add to make it play only ONCE?


Here's the script:
brick=script.Parent
other=brick.Parent.play
music=brick.Parent.music


function onHit(hit)
music:Play()
end

script.Parent.Touched:connect(onHit)

I just would like to be told on what to add to make it play the sound once and never again.
Report Abuse
FrostOver is not online. FrostOver
Joined: 20 Jun 2013
Total Posts: 299
26 Jan 2016 06:42 PM
local played = false
function onHit(hit)
played = true
music:Play()
end
Report Abuse
FrostOver is not online. FrostOver
Joined: 20 Jun 2013
Total Posts: 299
26 Jan 2016 06:43 PM
sorry
local played = false
function onHit(hit)
if not played then
played = true
music:Play()
end
end
Report Abuse
HuskiesPancake is not online. HuskiesPancake
Joined: 12 Apr 2013
Total Posts: 2623
26 Jan 2016 06:44 PM
^^^^^


#code print "Hello World!'
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image