I made a script to test if a toggle mechanism worked. This is what it was:
toggle = false
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
toggle = true
print("ToggledOn")
toggle = false
end)
end)
end)
if toggle == false then
print("ToggledOff")
end
so originally toggle is equal to false. If the player dies, then toggle is equal to true which prints ("ToggledOn"). then it is reset, and toggle is equal to false again and it should print ("Toggledoff"). My problem is that it isn't printing Toggled off, only ToggledOn after the humanoid dies. Can someone help me with this?

1 comment
if anyone knows a more optimized way of doing this please lmk