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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|