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: Music plays when you hit a certain block.

Previous Thread :: Next Thread 
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 02:30 PM
I want to play radioactive when somone passes through a certain block cause I have a skydiving game and it would make it epic, I have the chat voice thing (Don't know if this is in right forum or what ever)
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
10 Nov 2013 02:32 PM
script.Parent.Touched:connect(function()
--Play music
end)

http://wiki.roblox.com/index.php/Touched_(Event)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 03:22 PM
What do you mean "Play music"? Do you mean put the id of the music? Cause that's all I have.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
10 Nov 2013 03:24 PM
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local s = Instance.new("Sound",hit.Parent.Head)
s.SoundId = ?
s:Play()
end
end)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 04:50 PM
Do I have to put audio in the soundscape or in lighting or something? I tried it the script but it didn't work
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
10 Nov 2013 04:55 PM
make sure us have the asset url, not iust the id. its something like roblox.com/asset/(randomsymobls)id=
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
10 Nov 2013 05:00 PM


Find the ID of the sound, and replace the 0 in "local id = 0;" with your ID.

local id = 0;
local debounce = false;

script.Parent.Touched:connect(function(hit)
if debounce then return end
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
debounce = true;
local s = Instance.new("Sound", script.Parent);
s.SoundId = id;
s.PlayOnRemove = true;
s:Destroy();
wait(1);
debounce = false;
end
end)

I added in a debounce so the sound wouldn't be spammed by just touching the brick. You should set the wait-time to the length of the sound if you don't want the sound to play when it already is playing.
Report Abuse
FrozenSmite is not online. FrozenSmite
Joined: 17 Jul 2013
Total Posts: 2242
10 Nov 2013 05:05 PM
@Above i think u need a "http://www.roblox.com/asset/?id="

♫♪ repeat wait() until game.Players.FrozenSmite.HasALife == true ♪♫
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
10 Nov 2013 05:06 PM
OH snap! I wrote the first line before I started the script, just assumed I would remember it.

Correct, the "local id = 0;" should be
"local id = http://www.roblox.com/asset/?id=0";
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 05:11 PM
That creates an error for me?
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
10 Nov 2013 05:14 PM
What is the error? And what was the final script?

It should look like this:

local id = "http://www.roblox.com/?id=0";
local debounce = false;

script.Parent.Touched:connect(function(hit)
if debounce then return end
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
debounce = true;
local s = Instance.new("Sound", script.Parent);
s.SoundId = id;
s.PlayOnRemove = true;
s:Destroy();
wait(1);
debounce = false;
end
end)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 05:34 PM
Final script is,

local id = "http://www.roblox.com/?id=131111368";
local debounce = false;

script.Parent.Touched:connect(function(hit)
if debounce then return end
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
debounce = true;
local s = Instance.new("Sound", script.Parent);
s.SoundId = id;
s.PlayOnRemove = true;
s:Destroy();
wait(1);
debounce = false;
end
end)


Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 05:46 PM
woopsie forgot /asset/ in the url I put that in script just didnt write it in forum.
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
10 Nov 2013 06:19 PM
Try this, then:

local id = "http://www.roblox.com/asset/?id=131111368";
local debounce = false;

script.Parent.Touched:connect(function(hit)
if debounce then return end
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
debounce = true;
local s = Instance.new("Sound", script.Parent);
s.SoundId = id;
s:Play();
wait(1);
debounce = false;
end
end)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 06:21 PM
Nope didnt work.
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 06:25 PM
Nvm It did work but how do i make it louder?
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 06:33 PM
AND it only works in test thing in studio. :(
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
10 Nov 2013 09:08 PM
Bumb.....
Report Abuse
DevilDefeater is not online. DevilDefeater
Joined: 08 Jul 2013
Total Posts: 756
10 Nov 2013 09:11 PM
Omg, do anyone of you guys know anything about :Play()???

script.Parent.Touched:connect(function(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
script.Music:Play()
end
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Nov 2013 09:11 PM
Yes, it plays a sound
But I don't know if sounds play in scripts
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
11 Nov 2013 08:39 AM
bump
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