Clientside ignore script breaks when target respawns, no events are firing

I am making an ignore script for my game, and it works fine most of the time. It creates a part (parented to the target) locally and creates a weld between it and the HumanoidRootPart.

Recently, I discovered that the script breaks when the target resets, which is odd since I have this bit of code that prevents that:

--The existence of this object is to later undo the ignore by destroying it
local ignoreLabel = Instance.new("StringValue") 
ignoreLabel.Name = "__IGNORED"
--Parented to the player object, retrieved by looping through Players:GetChildren()
ignoreLabel.Parent = targetPlayer 

hideChar(v.Character) --Creates the weld to 0,0,0 to the HRP
local cn = v.CharacterAdded:Connect(function(char)
	print("character added")
	hideChar(char) --Creates the weld to 0,0,0 to the HRP
end)

--When the unignore script destroys __IGNORED then it will stop applying the weld on spawn
ignoreLabel:GetPropertyChangedSignal("Parent"):Connect(function()
	print("parent changed")
	cn:Disconnect()
end)

I would think this code works fine, but when I test it, neither CharacterAdded nor GetPropertyChangedSignal fire at all!

This means that the ignored player can simply reset and is scott-free!

Please note that this is all in a LocalScript, so that may be the cause of my issues. I have been stumped on this for hours and tested vigorously, I hope somebody can help with this.

Could you show us any possible error(s) you’re getting?

Could we see the entire script please, it is for us to hard to help you with only a piece of the code.

No errors in the console whatsoever

Here is the whole localscript for the block button. It is apart of a gui object that corresponds to each player.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local localplayer = Players.LocalPlayer
local frame = script.Parent.Parent
local blockedPlayer = frame:WaitForChild("BlockedPlayer")
local guiEvent = frame:WaitForChild("AddEvent") --allows 'add all' to trigger it
local IgnoreEvent = ReplicatedStorage:WaitForChild("IgnoreEvent")

local function hideChar(char)
	local IgnorePart = Instance.new("Part")
	IgnorePart.Anchored = true
	IgnorePart.CFrame = CFrame.new(0,-5000,0) --FallenPartsDestroyHeight is -25000
	IgnorePart.Transparency = 1
	IgnorePart.Name = "__IGNOREPART"
	local HRP = char:WaitForChild("HumanoidRootPart")
	local IgnoreWeld = Instance.new("Weld")
	if HRP.Anchored then
		for i,v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				v.Anchored = false
			end
		end
	end
	IgnorePart.Parent = char
	IgnoreWeld.Part0 = HRP
	IgnoreWeld.Part1 = IgnorePart
	IgnoreWeld.Name = "__IGNOREWELD"
	IgnoreWeld.Parent = IgnorePart
end

local function addplr()
	local targ = blockedPlayer.Text

	for _,v in pairs(Players:GetChildren()) do
		if v ~= localplayer and v.Name == targ then

			--Tells server to add to serverside list for tracking
			IgnoreEvent:FireServer(v) 
			
			if not v:FindFirstChild("__IGNORED") then --make sure it doesn't double block
				--randomly a stringvalue, only the name matters
				local ignoreLabel = Instance.new("StringValue") 
				ignoreLabel.Name = "__IGNORED"
				ignoreLabel.Parent = v

				hideChar(v.Character)
				local cn = v.CharacterAdded:Connect(function(char)
					print("character added")
					hideChar(char)
				end)

				ignoreLabel:GetPropertyChangedSignal("Parent"):Connect(function()
					print("parent changed")
					cn:Disconnect()
				end)
			end
			
			break
		end
	end
end

guiEvent.Event:Connect(addplr)

script.Parent.MouseButton1Click:connect(function()
	guiEvent:Fire()
end)

EDIT:
The player gets hidden initially, but when they respawn they don’t get re-hidden. Furthermore, nothing prints when they respawn, which should happen. If I unblock them, the ignoreLabel:GetPropertyChangedSignal("Parent") does not fire, even though the ignore label is destroyed.

There is absolutely no console activity whatsoever. I am testing on a 2 player localserver.

Here’s the code for unblocking if it helps

local frame = script.Parent.Parent
local targ = frame:WaitForChild("BlockedPlayer").Text
local guiEvent = frame:WaitForChild("DeleteEvent") --allows clear all to trigger deletion
local IgnoreEvent = game:GetService("ReplicatedStorage"):WaitForChild("IgnoreEvent")
local Players = game:GetService("Players")

guiEvent.Event:Connect(function()
	local target = Players:FindFirstChild(targ)
	if target then
		IgnoreEvent:FireServer(target, true)
		local ignorepart = target.Character:FindFirstChild("__IGNOREPART")
		if ignorepart then
			ignorepart:Destroy() --destroying the part also takes the weld with it
		end
		local ignoreobj = target:FindFirstChild("__IGNORED")
		if ignoreobj then
			ignoreobj:Destroy() --this tells the connection to destroy itself so the welds stop being added on spawn
		end
	end
end)

script.Parent.MouseButton1Click:connect(function()
	guiEvent:Fire()
end)

The reason that the :GetPropertyChangedSignal doesn’t fire is because the Ignorepart is created on the client, therefore the following check when done on the server will return false and won’t destroy the part, because it doesn’t exist on the server:

Honestly there shouldn’t be any need to handle this on the server, you can probably just move that code from the server into a function in the local script and call that function when they unblock.

Then your other problem, is the problem that when you respawn, the other players go back to visible. Or is it that when they respawn, they go back to visible for u?

This is all a localscript, the server only keeps track of the list.
Edit: also, the ignoreobj gets destroyed on the client, I can verify with the explorer.

Sorry I should have been more clear, the bug occurs when the target respawns, when the player respawns nothing unexpected happens.

I believe that the changed event doesn’t fire because when it is destroyed, the parent doesn’t change, it is just gone. Try this instead:

v.ChildRemoved:Connect(function(child)
	if child == ignoreLabel then	
           print("Disconnecting")
	       cn:Disconnect()
    end
end)

Also when does guiEvent.Event fire?

The event is fired when the button is clicked, or when the “set all” button tells it to.

I’ll try that, but it still won’t solve the problem of CharacterAdded not firing as well

This did not solve the problem either. I suspect it has something to do with it being a player object?

UPDATE: I have fixed the bug in my game by firing an event to all clients when a player respawns, this tells the ignore script to hide the player’s character. I did away with “__IGNORED” and instead just checked the serverside list of ignored players. Sorry that this bug has not been fixed, I just worked around it, I have no idea why the bug happens.