Hello,
The script I am working on is supposed print a message when a specific instance named ‘isPlaying’ is removed. However, the script does not seem to function.
(Note: The Instance is removed when the Humanoid dies)
game.Players.PlayerAdded:Connect(function(player)
player.ChildRemoved:Connect(function()
wait(1)
local isPlaying = player:FindFirstChild("isPlaying")
if isPlaying == nil then
print("Player is not playing")
end
end)
end)
are you removing the instance with a local script? if so then the change will not be replicated to the server and this script will still see the instance as being there
You could just grab the child that was removed by doing Child removed:Connect(function(instance) and then check the name of that instance, that way you can see that the is playing object was removed
I would listen through AncestryChanged on the child objects parent.
local isPlaying = player:FindFirstChild("isPlaying")
if isPlaying then
isPlaying.AncestryChanged:Connect(function(_, parent)
if not parent then
print("Player is not playing")
end
end)
end
Or listen to the humanoid
humanoid.Died:Connect(function()
print("Player died and is not playing")
end)