This isn't working. Is there anything I am doing wrong? This script is suppose to find the player who touches the brick (the brick is a doorway and is invisible), and if the audio is playing, it would pause the audio, but if the player's audio is paused, it would play the audio rather.
function onTouch(hit)
local a = game.Players.LocalPlayer.PlayerGui.Sound.IsPlayed
local b = game.Players.LocalPlayer.PlayerGui.Sound.IsPaused
if a ~= nil then
game.Players.LocalPlayer.PlayerGui.Sound:Pause()
else
if b ~= nil then
game.Players.LocalPlayer.PlayerGui.Sound:Play()
end
end
end
script.Parent.Touched:connect(onTouch)

6 comments
Still didn't work :p
You are using localplayer, you have to get the player using GetPlayerFromCharacter method.
Check my answer.
Yeah but you could be more efficient just by calling the GetPlayerFromCharacter function once instead of 4 times.
Thats not a function.. Thats a method
Methods are functions. So it is a function since all methods are functions.