Script doesn't play audio

ik im asking him to put a print to check if the sound got played

I also tried that before, didn’t work

here is the place file
Main.rbxl (46.8 KB)

local DB = true

script.Parent.Touched:Connect(function(hit)
	
	if DB then
		DB = false
		if hit:FindFirstAncestorWhichIsA("Model") then
			local Character :Model = hit:FindFirstAncestorWhichIsA("Model")
			print(Character)
			if Character:FindFirstChildWhichIsA("Humanoid") then
				print("Player")
				local plr = game.Players:GetPlayerFromCharacter(Character)
				print(plr)
				game.ReplicatedStorage.Remotes.Intro.VoiceIntro1:FireClient(plr)
			end
		end
		wait(0.1)
		DB = true
	end
end)

– I just modified the part of the touch and fireclient

Just do

Sound:Play()

LocalScript are scripts ran on the client (Your operating system / roblox window)
It won’t play for anyone else when using it due to the fact its done in a LocalScript.
And also do

WhereverSoundIs:WaitForChild("SoundName")

.-. he wants whend the part its touch not all the time -.-

The current part touching would work no matter what.

try not to use .touched, it’s incredibly unreliable.

instead, i highly suggest zonesplus


check the sound

Just noticed something. You are trying to get PlayerGui from the Players service. Maybe assign Player to the localplayer?

local Player = game:GetService("Players")

local SoundService = game:GetService("SoundService")

local Subtitle = Player:WaitForChild("PlayerGui"):WaitForChild("Subtitles"):WaitForChild("Subtitle")

Instead, do:

local Player = game:GetService("Players").LocalPlayer

Found the issue…?
image

local Player = game:GetService("Players").LocalPlayer
local SoundService = game:GetService("SoundService")
local Subtitle = Player:WaitForChild("PlayerGui"):WaitForChild("Subtitles"):WaitForChild("Subtitle")
local SoundFolder = game.Workspace.Narration
local Remotes = game.ReplicatedStorage.Remotes

--//Intro Narration
Remotes.Intro.VoiceIntro1.OnClientEvent:Connect(function(plr)
	local VoiceIntro1 = SoundFolder.Intro.SecondAudio
	SoundService:PlayLocalSound(VoiceIntro1)
	--subtitle.Text = "Text"
end)

image
another problem at line 3 in the local script

Yeah. PlayerGui will never be a member of game.Players normally. You have to assign the player variable to the LocalPlayer rather than the service.


you are actually asking the whole service for the player gui

PlayerGui isn’t part of the Players service. It’s part of a Player object. To fix that error you would do:

local Player = game:GetService("Players").LocalPlayer
local SoundService = game:GetService("SoundService")
local Subtitle = Player:WaitForChild("PlayerGui"):WaitForChild("Subtitles"):WaitForChild("Subtitle")

I will check all of these, I am having some issues with roblox studio atm though

Meant to go to @WonderWorksXD not you by the way mh.

Pretty sure that’s going to be the fix; however if it isn’t send another code snippet of your current LocalScript after you add the .LocalPlayer part. If there is an infinite yield the OnClientEvent listener will never start.

I will also check this out, it seems cool and helpful in most situations

this worked, though I had to tweak it a bit. Thanks for the help.

1 Like