.Changed not working after a player resets

As the title says, I am having trouble with a .Changed event not connecting after a player has died/reset.

local player =game:WaitForChild("Players").LocalPlayer

player.Character.Sound.Changed:Connect(function()

	if player.Character.Sound.Playing == true then
--Do my code
end
end)

You need to reconnect it everytime player dies/reset

One of the solution is to put the LocalScript into “StarterCharacterScript” and index the character like this:

local character = script.Parent
1 Like
local player = game:WaitForChild("Players").LocalPlayer

local function connectCharacter(character)
	character.Sound.Changed:Connect(function()
		if character.Sound.Playing == true then
			--Do my code
		end
	end)
end

player.CharacterAdded:Connect(connectCharacter)

local character = player.Character
if character then
	connectCharacter(character)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.