Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My sound playing script doesn't work in-game, how can i fix it?

Asked by 5 years ago

so i made a script where i put sounds "sound1 - sound6" in the StarterGUI, and in this script, it would play Sound1 and it would stop Sound2 - Sound6 when i enter a block that this code is put in, but it only works in Studio, and i have no idea why it doesn't work in-game... Anyone able to help?


Sound starting script:

script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then game.Players[hit.Parent.Name].PlayerGui.Sound2:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound3:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound4:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound5:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound6:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound1.Volume = 1 game.Players[hit.Parent.Name].PlayerGui.Sound1:Play() end end)

Sound ending script (when leaving the block):

script.Parent.TouchEnded:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then game.Players[hit.Parent.Name].PlayerGui.Sound1.Volume = 0 end end)

0
You shouldn’t be accessing PlayerGui from the server. User#19524 175 — 5y
0
Alright.. So what do i do to fix that? I'm not very adept at scripting.. the_silenced 0 — 5y

Answer this question