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
 

Re: Touched event music block help

Previous Thread :: Next Thread 
radj02 is not online. radj02
Joined: 21 May 2014
Total Posts: 6
15 Aug 2016 09:33 PM
So, I've been trying to get it so that when you touch an invisible, "can't collide" block, the current audio file that's playing stops and a new one starts playing, but nothing's working. What do I need to do?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
15 Aug 2016 10:32 PM
local sound = part.Sound

part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
sound:Stop()
sound.SoundId = 'rbxassetid://234234324'
sound:Play()
end
end)


Report Abuse
radj02 is not online. radj02
Joined: 21 May 2014
Total Posts: 6
19 Aug 2016 04:29 PM
What do I need to put the script in?
Report Abuse
ParaText is not online. ParaText
Joined: 15 Aug 2016
Total Posts: 799
19 Aug 2016 04:30 PM
The part itself, and don't forget to add debounce
http://wiki.roblox.com/index.php?title=Debounce
Report Abuse
radj02 is not online. radj02
Joined: 21 May 2014
Total Posts: 6
22 Aug 2016 02:15 PM
Ok, here's what I have:

local part = game.Workspace.PinkBlock --The part I want to embed the script into.
local sound = part.Sound

part.Touched:connect(debounce(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
sound:Stop()
sound.SoundId = 'rbxasset://184290611'
sound:Play()
end
end))

What ends up happening is the song I want to play when the block is touched plays when I spawn, instead, meanwhile the song I want to play when I spawn doesn't play. How can I fix that?
Report Abuse
radj02 is not online. radj02
Joined: 21 May 2014
Total Posts: 6
24 Aug 2016 05:13 PM
OK, I've changed the script to this

local part = game.Workspace.PinkBlock
local sound = game.Players.LocalPlayer.PlayerGui.Sound

part.Touched:connect(debounce(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
sound:Stop()
sound.SoundId = 'rbxassetid://184290611'
sound:Play()
end
end))

I have yet to test this, but I'll update soon.
Report Abuse
radj02 is not online. radj02
Joined: 21 May 2014
Total Posts: 6
24 Aug 2016 06:03 PM
OK, that didn't work. I changed the Sound ID to the spawn music and saved it, but it changed back for no reason. I need help with this.
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