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: Remove audio

Previous Thread :: Next Thread 
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
28 Dec 2015 11:23 PM
So I have this script
it clones a sound from the workspace into the playerGui so only one person hears the audio when they touch a certain block
anyway I want to remove the sound when a player touches a different block and play the a different audio
I have this script right now

local Sound = game.Workspace.Termina:Clone()
game.Workspace.TerminField.Touched:connect(function(Hit)
if game.Players:GetPlayerFromCharacter(Hit.Parent) ~= nil then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player.PlayerGui:FindFirstChild(Sound.Name) == nil then
Sound.Parent = Player.PlayerGui
Sound:Play()
end
end
end)


Just need to remove a sound that already exists in the playerGui which is named Clocktown
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
28 Dec 2015 11:31 PM
I tried a few things but the audio just played over each other
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
28 Dec 2015 11:36 PM
hmmmmm
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
28 Dec 2015 11:38 PM
bump
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
28 Dec 2015 11:42 PM
bump x2
Report Abuse
usermvp is not online. usermvp
Joined: 29 Jun 2013
Total Posts: 188
28 Dec 2015 11:52 PM
Try this;

--// Variables

local workspace = game:GetService('Workspace')
local sound1 = workspace:WaitForChild('Sound1')
local sound2 = workspace:WaitForChild('Sound2')
local field1 = workspace:WaitForChild('Field1')
local field2 = workspace:WaitForChild('Field2')

--// Script

field1.Touched:connect(function(hit)
if game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) ~= nil then
local player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
local playergui = player:WaitForChild('PlayerGui')
if player and playergui then
if playergui:FindFirstChild(sound1.Name) == nil then
sound1.Parent = playergui
sound1:Play()
end
end
end
end)

field2.Touched:connect(function(hit)
if game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) ~= nil then
local player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
local playergui = player:WaitForChild('PlayerGui')
if player and playergui then
if playergui:FindFirstChild(sound2.Name) == nil then
sound2.Parent = playergui
sound2:Play()
end
end
end
end)

~Previously known as Zztheses
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:00 AM
@user
should I be changing anything about that?
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:04 AM
bump
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:06 AM
qq
Report Abuse
usermvp is not online. usermvp
Joined: 29 Jun 2013
Total Posts: 188
29 Dec 2015 12:07 AM
Yes, change sound1 to your first sound name, change sound2 to the second sound name

Change field1 to your first part that you want it to play the sound on, change field2 to your second part that you want it to play another sound

~Previously known as Zztheses
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:10 AM
@user
plays the second audio but doesn't remove the first one
Report Abuse
usermvp is not online. usermvp
Joined: 29 Jun 2013
Total Posts: 188
29 Dec 2015 12:10 AM
In the 2nd part of the script under sound2:Play() do

sound1:Stop()

and if that does't work

sound1:Pause()

~Previously known as Zztheses
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:14 AM
@user
yay
thank you
this script has caused me so much trouble and now I got it working
you're the best
Report Abuse
usermvp is not online. usermvp
Joined: 29 Jun 2013
Total Posts: 188
29 Dec 2015 12:15 AM
You're welcome. Also in the first part add

sound2:Pause() or sound2:Stop() so it makes sure it's not playing, if it is it'll pause

~Previously known as Zztheses
Report Abuse
crazyawsomejames is not online. crazyawsomejames
Joined: 16 Apr 2012
Total Posts: 16167
29 Dec 2015 12:15 AM
however development for my game is still at a standstill until roblox fixes the CSG physics qq
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