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 » Scripting Helpers
Home Search
 

Re: Sound Help?

Previous Thread :: Next Thread 
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 01:55 AM
What would be the most efficient script for playing sounds in bricks once the bricks are in workspace. (For example: if Brick is in workspace then = Play sound, if Brick is in lighting then = sound False) This is kind of the script I need. Please forgive me, because I am not a good scripter :p
Report Abuse
iValianT is not online. iValianT
Joined: 21 Aug 2010
Total Posts: 58381
08 Mar 2014 01:57 AM
ok
so


p = script.Parent

if p.Parent == Workspace then
p.sound:Play
else
p.sound:Stop()
end
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 02:33 AM
Studio is reading a script error in that on the line that says: else
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
08 Mar 2014 02:39 AM
try dis yo

part = script.Parent
soundID = 123456
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..soundID)
if part.Parent == game:GetService("Workspace") then
audio = Instance.new("Sound", game.Workspace)
audio.SoundId = soundID
audio.Volume = 1
wait(0.2)
audio:Play()
elseif part.Parent == game:GetService("Lighting") then
audio:Stop()
wait(0.1)
audio:Destroy()
end
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
08 Mar 2014 02:45 AM
You guys don't understand, it won't stop when it is in Lighting because the script would have stopped (scripts don't run in Lighting)
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
08 Mar 2014 03:08 AM
skripts dont run in lighting? hmm i did nawt kno dat

part = game:GetService("Workspace"):FindFirstChild("Part")
soundID = 123456
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..soundID)
if part.Parent == game:GetService("Workspace") then
audio = Instance.new("Sound", game.Workspace)
audio.SoundId = soundID
audio.Volume = 1
wait(0.2)
audio:Play()
elseif part.Parent == game:GetService("Lighting") then
audio:Stop()
wait(0.1)
audio:Destroy()
end

problem solvd
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 04:44 PM
If the brick was inside of a model would I add an extra Parent. to the script?
Report Abuse
iValianT is not online. iValianT
Joined: 21 Aug 2010
Total Posts: 58381
08 Mar 2014 05:05 PM
yes
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 05:13 PM
Hmmm I did, but nothing happened once the model and brick entered workspace...
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 05:33 PM
B1
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
08 Mar 2014 05:46 PM
B2
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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