|
| 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 |
|
|
|
| 28 Dec 2015 11:31 PM |
| I tried a few things but the audio just played over each other |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
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 |
|
|
|
| 29 Dec 2015 12:00 AM |
@user should I be changing anything about that? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
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 |
|
|
|
| 29 Dec 2015 12:10 AM |
@user plays the second audio but doesn't remove the first one |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|